比赛 20161116 评测结果 AAAWWWWWWW
题目名称 删除他们! 最终得分 30
用户昵称 jinqiu 运行时间 0.003 s
代码语言 C++ 内存使用 0.28 MiB
提交时间 2016-11-16 09:16:04
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int n, m, q, last, ans;

int main() {
	freopen("deleteit.in", "r", stdin);
	freopen("deleteit.out", "w", stdout);
	int i;
	cin >> n >> m >> q;
	ans = n*m;
	for(i = 1; i <= q; i++) {
		int x1, y1, x2, y2;
		int jianshao;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if(n >= x1 + 1 && n >= x2 + 1) {
			jianshao = abs(x2 - x1 + 1)*abs(y2 + 1 - y1);
			ans -= jianshao;
			n = ans/m;
			last = ans % m;
		}
		else if(n < max(x1 + 1, x2 + 1)) {
			jianshao = abs(n - min(x1, x2))*abs(y2 + 1 - y1);
			jianshao += (last - min(y2, y1)) > 0 ? last - min(y1, y2): 0;
			ans -= jianshao;
			n = ans/m;
			last = ans % m;
		}
	}
	cout << ans << "\n";
	return 0;
}