社区讨论

20分求解

P5542[USACO19FEB] Painting The Barn S参与者 2已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@lo7dpgi6
此快照首次捕获于
2023/10/27 00:08
2 年前
此快照最后确认于
2023/10/27 00:08
2 年前
查看原帖
CPP
#include<iostream>
#include<cstring>
using namespace std;
int n, k;
int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	int x, y, xx, yy, a[n + 2][n + 2] = {0};
	for (int i = 1; i <= n; i++) {
		cin >> x >> y >> xx >> yy;
		a[x + 1][y + 1]++;
		a[xx + 1][yy + 1]++;
		a[x + 1][yy + 1]--;
		a[xx + 1][y + 1]--;
	}
	int ans = 0;
	for (int i = 1; i <= 1000; i++) {
		for (int j = 1; j <= 1000; j++) {
			a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
			if (a[i][j] == k) {
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...