//4108k, 485ms
#include <cstdio>
#include <cstring>
using namespace std;
int c[1010][1010] ;
int lowbit(int x)
{
return x & -x ;
}
void add(int i,int j,int d)
{
int x , y ;
for(x = i ; x > 0 ; x -= lowbit(x))
for(y = j ; y > 0 ; y -= lowbit(y))
c[x][y] += d;
}
int sum(int i,int j,int n)
{
int a = 0 , x , y ;
for(x = i ; x <= n ; x += lowbit(x))
for(y = j ; y <= n ; y += lowbit(y))
a += c[x][y] ;
return a ;
}
int main()
{
int t , tt , i , j , n , m , x1 , y1 , x2 , y2 ;
char ch ;
scanf("%d", &t);
for(tt = 1 ; tt <= t ; tt++)
{
scanf("%d %d", &n, &m);
memset(c,0,sizeof(c));
while(m--)
{
getchar();
scanf("%c", &ch);
if( ch == 'C' )
{
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
add(x2,y2,1);
add(x1-1,y2,-1);
add(x2,y1-1,-1);
add(x1-1,y1-1,1);
}
else
{
scanf("%d %d", &x1, &y1);
printf("%d\n", sum(x1,y1,n)%2 );
}
}
if(tt != t)
printf("\n");
}
return 0;
}
转载于:https://www.cnblogs.com/StevenL/p/6818284.html