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.

56 lines
1.3 KiB

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <math.h>
#include <cstdio>
using namespace std;
#define lowbit(x) (x & -x)
const int N = 1010;
//用树状数组存储二分差分数组
int t[N][N];
int n;
void add(int x, int y, int w) {
for (int i = x; i <= n; i += lowbit(i))
for (int j = y; j <= n; j += lowbit(j))
t[i][j] += w;
}
int sum(int x, int y) {
int ans = 0;
for (int i = x; i > 0; i -= lowbit(i))
for (int j = y; j > 0; j -= lowbit(j))
ans += t[i][j];
return ans;
}
int main() {
char str[2];
int T;
scanf("%d", &T);
while (T--) {
int k;
scanf("%d %d", &n, &k);
memset(t, 0, sizeof(t));
while (k--) {
scanf("%s", str);
if (str[0] == 'C') {
int x1, x2, y1, y2;
scanf("%d %d %d %d", &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;
scanf("%d %d", &x, &y);
printf("%d\n", sum(x, y) % 2);
}
}
if (T) puts("");
}
}