1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
const long long p = 3;
const int MAX = 2500;
int n, m, q, t, x1, y1, x2, y2;
long long c[MAX+2][MAX+2];
map<pair<pair<int, int>, pair<int, int> >, long long> mp;
int LowBit(int x) {
return x&(-x);
}
void Add(int x, int y, long long v) {
for(int i=x; i<=n; i+=LowBit(i)) {
for(int j=y; j<=m; j+=LowBit(j)) {
c[i][j] += v;
}
}
}
long long Sum(int x, int y) {
long long sum = 0;
for(int i=x; i>=1; i-=LowBit(i)) {
for(int j=y; j>=1; j-=LowBit(j)) {
sum += c[i][j];
}
}
return sum;
}
int main(int argc, char const *argv[]) {
scanf("%d %d %d", &n, &m, &q);
long long val = 1;
while(q--) {
scanf("%d %d %d %d %d", &t, &x1, &y1, &x2, &y2);
if(t == 1) {
val *= p;
mp[make_pair(make_pair(x1, y1), make_pair(x2, y2))] = val;
Add(x1, y1, val);
Add(x1, y2+1, -val);
Add(x2+1, y1, -val);
Add(x2+1, y2+1, val);
}
if(t == 2) {
long long tmp = mp[make_pair(make_pair(x1, y1), make_pair(x2, y2))];
Add(x1, y1, -tmp);
Add(x1, y2+1, tmp);
Add(x2+1, y1, tmp);
Add(x2+1, y2+1, -tmp);
}
if(t == 3) {
if(Sum(x1, y1) == Sum(x2, y2))
printf("Yes\n");
else printf("No\n");
}
}
return 0;
}
|