You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
#include <iostream>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
const int N = 1010;
|
|
using namespace std;
|
|
|
|
int n, m;
|
|
string str;
|
|
int c[N][N];
|
|
|
|
#define lowbit(x) (x & -x)
|
|
void add(int x, int y, int v) {
|
|
for (int i = x; i < N; i += lowbit(i))
|
|
for (int j = y; j < N; j += lowbit(j))
|
|
c[i][j] += v;
|
|
}
|
|
|
|
int sum(int x, int y) {
|
|
int res = 0;
|
|
for (int i = x; i; i -= lowbit(i))
|
|
for (int j = y; j; j -= lowbit(j))
|
|
res += c[i][j];
|
|
return res;
|
|
}
|
|
|
|
int main() {
|
|
// 加快读入
|
|
ios::sync_with_stdio(false), cin.tie(0);
|
|
int T;
|
|
cin >> T;
|
|
while (T--) {
|
|
memset(c, 0, sizeof(c));
|
|
cin >> n >> m;
|
|
while (m--) {
|
|
cin >> str;
|
|
if (str[0] == 'C') {
|
|
int x1, y1, x2, y2;
|
|
cin >> x1 >> y1 >> x2 >> y2;
|
|
// 二维差分
|
|
add(x1, y1, 1);
|
|
add(x2 + 1, y1, -1);
|
|
add(x1, y2 + 1, -1);
|
|
add(x2 + 1, y2 + 1, 1);
|
|
} else {
|
|
int x, y;
|
|
cin >> x >> y;
|
|
printf("%d\n", sum(x, y) % 2);
|
|
}
|
|
}
|
|
if (T) puts("");
|
|
}
|
|
return 0;
|
|
} |