标签:
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 25004 | Accepted: 9261 |
Description
Input
Output
Sample Input
1 2 10 C 2 1 2 2 Q 2 2 C 2 1 2 1 Q 1 1 C 1 1 2 1 C 1 2 1 2 C 1 1 2 2 Q 1 1 C 1 1 2 1 Q 2 1
Sample Output
1 0 0 1
Source
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int bit[1010][1010]; 5 int n; 6 int lb(int x){ 7 return x&(-x); 8 } 9 int q(int x,int y){ 10 int ans=0; 11 while(x){ 12 int i=y; 13 while(i){ 14 ans+=bit[x][i]; 15 i-=lb(i); 16 } 17 x-=lb(x); 18 } 19 return ans%2; 20 } 21 int c(int x,int y){ 22 while(x<=n+5){ 23 int i=y; 24 while(i<=n+5){ 25 bit[x][i]++; 26 i+=lb(i); 27 } 28 x+=lb(x); 29 } 30 return 0; 31 } 32 int main(){ 33 int T; 34 scanf("%d",&T); 35 while(T--){ 36 int t; 37 scanf("%d %d",&n,&t); 38 memset(bit,0,sizeof(bit)); 39 for(int i=1;i<=t;i++){ 40 char op=getchar(); 41 while(op!=‘C‘&&op!=‘Q‘)op=getchar(); 42 switch(op){ 43 case ‘C‘: 44 int x1,y1,x2,y2; 45 scanf("%d %d %d %d",&x1,&y1,&x2,&y2); 46 c(x1,y1); 47 c(x2+1,y1); 48 c(x1,y2+1); 49 c(x2+1,y2+1); 50 break; 51 case ‘Q‘: 52 int x,y; 53 scanf("%d %d",&x,&y); 54 printf("%d\n",q(x,y)); 55 break; 56 default: 57 break; 58 } 59 } 60 puts(""); 61 } 62 return 0; 63 }
标签:
原文地址:http://www.cnblogs.com/Pumbit-Legion/p/5824113.html