[Cpp] # include <stdio. h ># include <cstring> const int maxn = 1001; int c [maxn] [maxn]; inline int lowbit (int x) {return x & (-x );} 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 + = c [I] [j]; return ans;} void update (int x, int y, int p) {for (int I = x; I <maxn; I + = lowbit (I) for (int j = y; j <maxn; j + = lowbit (j) c [I] [j] + = p;} int main () {int t, n, test, f = 0; int x1, x2, y1, y2; char op; scanf ("% d", & t); while (t --) {memset (c, 0, sizeof (c )); if (f = 1) printf ("\ n"); f = 1; scanf ("% d", & n, & test); while (test --) {scanf ("% c", & op); if (op = 'C') {www.2cto.com scanf ("% d", & x1, & y1, & x2, & y2); update (x2 + 1, y2 + 1); update (x1, y2 + 1,-1); update (x2 + 1, y1,-1); update (x1, y1, 1);} else if (op = 'q') {scanf ("% d", & x1, & y1); printf ("% d \ n", sum (x1, y1) % 2) ;}} return 0 ;}