标签:res ring ogr space algorithm script scan printf owb
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 17226 | Accepted: 6461 |
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
1 0 0 1
1 //2017-10-25 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 1100; 10 11 int bt[N][N], n, q; 12 13 int lowbit(int x){ 14 return x&(-x); 15 } 16 17 void add(int x, int y, int v){ 18 while(x <= n){ 19 int j = y; 20 while(j <= n){ 21 bt[x][j] += v; 22 j += lowbit(j); 23 } 24 x += lowbit(x); 25 } 26 } 27 28 int sum(int x, int y){ 29 int sm = 0; 30 while(x > 0){ 31 int j = y; 32 while(j > 0){ 33 sm += bt[x][j]; 34 j -= lowbit(j); 35 } 36 x -= lowbit(x); 37 } 38 return sm; 39 } 40 41 int main() 42 { 43 int T; 44 cin>>T; 45 while(T--){ 46 scanf("%d%d", &n, &q); 47 memset(bt, 0, sizeof(bt)); 48 char op; 49 int x, y, x1, y1; 50 while(q--){ 51 getchar(); 52 scanf("%c%d%d", &op, &x, &y); 53 if(op == ‘C‘){ 54 scanf("%d%d", &x1, &y1); 55 add(x, y, 1); 56 add(x, y1+1, -1); 57 add(x1+1, y, -1); 58 add(x1+1, y1+1, 1); 59 }else{ 60 printf("%d\n", sum(x, y)%2); 61 } 62 } 63 } 64 65 return 0; 66 }
标签:res ring ogr space algorithm script scan printf owb
原文地址:http://www.cnblogs.com/Penn000/p/7732534.html