题目是让每次对一个子矩阵进行翻转(0变1,1变0),

然后有多次询问,询问某个点是0还是1

这题可以用二维的树状数组来解决,考虑传统的树状数组是改变某个点,然后查询某一段,
而这个题是改变某一段,查询某个点,需要进行一下转换,将原来的改值变成查询,
查询变成改值。改制时相当于对区间分别进行修改,而查询某个点时,
就是将 覆盖这个点的区间全加起来,然后把一维的改成二维的就可以了。
 
 
 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("DATA.txt","r",stdin)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000") using namespace std;
typedef long long LL ;
const int maxn = 1e3 + ;
int n, m;
int c[maxn][maxn];
void update(int x, int y) {
for (int i = x ; i <= n ; i += lowbit(i))
for (int j = y ; j <= n ; j += lowbit(j))
c[i][j]++;
}
int getans(int x, int y) {
int sum = ;
for (int i = x ; i > ; i -= lowbit(i))
for (int j = y ; j > ; j -= lowbit(j))
sum += c[i][j];
return sum;
}
int main() {
int t, x1, y1, x2, y2;
char op[];
scanf("%d", &t);
while(t--) {
mem(c, );
scanf("%d%d", &n, &m);
while(m--) {
scanf("%s", op);
if (op[] == 'C') {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
x1++, y1++, x2++, y2++;
update(x2, y2);
update(x1 - , y1 - );
update(x1 - , y2);
update(x2, y1 - );
} else {
int x, y;
scanf("%d%d", &x, &y);
printf("%d\n", getans(x, y) % );
}
}
printf("\n");
}
return ;
}
05-20 23:38