20分求解
查看原帖
20分求解
620232
prx1460楼主2022/12/8 13:31
#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;
}
2022/12/8 13:31
加载中...