注意:
- 注意要用 scanf
- 注意多测
#include <iostream>
#include <vector>
using namespace std;
int n,m,q;
vector <vector <int> > a;
void insert (int x1,int y1,int x2,int y2,int d) {
a[x1][y1] += d,a[x1][y2 + 1] -= d,a[x2 + 1][y1] -= d,a[x2 + 1][y2 + 1] += d;
}
int sum (int x1,int y1,int x2,int y2) {
return a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1];
}
int main () {
while (~scanf ("%d%d",&n,&m)) {
a.assign (n + 2,vector <int> (m + 2,0));
int k;
scanf ("%d",&k);
while (k--) {
int x1,y1,x2,y2;
scanf ("%d%d%d%d",&x1,&y1,&x2,&y2);
insert (x1,y1,x2,y2,1);
}
for (int i = 1;i <= n;i++) {
for (int j = 1;j <= m;j++) a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
for (int i = 1;i <= n;i++) {
for (int j = 1;j <= m;j++) a[i][j] = (bool)a[i][j];
}
for (int i = 1;i <= n;i++) {
for (int j = 1;j <= m;j++) a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
scanf ("%d",&q);
while (q--) {
int x1,y1,x2,y2;
scanf ("%d%d%d%d",&x1,&y1,&x2,&y2);
if (sum (x1,y1,x2,y2) == (x2 - x1 + 1) * (y2 - y1 + 1)) puts ("YES");
else puts ("NO");
}
}
return 0;
}
标签:HDU,x1,Monitor,int,d%,6514,x2,y1,y2
From: https://www.cnblogs.com/incra/p/17227749.html