TMD找bug找了一万年。。。一直re,跟题解对了2个小时md。
个人感想:强者就是脑子比你好使,完成同样的任务比你更快更好,然后拿出剩下的时间去享受生活(自闭时的所想,不代表个人观点)
题意:
分析:
模板背过
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e7 + 100;
const int inf = 0x3f3f3f3f;
int n, m;
int a[maxn];
int getid(int x, int y)
{
if(x < 1 || x > n || y > m) return 0;
return (x - 1) * m + y;
}
int main()
{
while(cin >> n >> m)
{
for(int i = 0; i <= n * m; i++) a[i] = 0;
int q;cin >> q;
for(int i = 1; i <= q; i++)
{
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
a[getid(x1, y1)]++;
a[getid(x2 + 1, y1)]--;
a[getid(x1, y2 + 1)]--;
a[getid(x2 + 1, y2 + 1)]++;
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[getid(i, j)] += a[getid(i, j - 1)] + a[getid(i - 1, j)] - a[getid(i - 1, j - 1)];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[getid(i, j)] = a[getid(i, j)] > 0;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[getid(i, j)] += a[getid(i - 1, j)] + a[getid(i, j - 1)] - a[getid(i - 1, j - 1)];
int p; cin >> p;
while(p--)
{
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
int sum = a[getid(x2, y2)] - a[getid(x2, y1 - 1)] - a[getid(x1 - 1, y2) + a[getid(x1 - 1, y1 - 1)]];
if(sum == (x2 - x1 + 1) * (y2 - y1 + 1)) cout << "YES" << endl;
else cout << "NO" << endl;
}
}
}