标签:clu esc rip out 数组 nes row -- element
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 31892 | Accepted: 11594 |
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
解体心得:
#include <algorithm>
#include <stdio.h>
#include <cstring>
using namespace std;
const int maxn = 1010;
int sum[maxn][maxn],n,m;
int lowbit(int x) {
return x&-x;
}
void add(int x,int y,int va) {
if(x < 1 || y < 1 || x > n || y > n)
return ;
for(int i=x;i<=n;i+=lowbit(i))
for(int j=y;j<=n;j+=lowbit(j))
sum[i][j] += va;
}
int Query(int x,int y) {
int Sum = 0;
for(int i=x;i>0;i-=lowbit(i))
for(int j=y;j>0;j-=lowbit(j))
Sum += sum[i][j];
return Sum;
}
int main() {
int t;
scanf("%d",&t);
while(t--) {
scanf("%d%d",&n,&m);
memset(sum,0,sizeof(sum));
while(m--) {
char s[3];
scanf("%s",s);
if(s[0] == ‘C‘) {
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
add(x1,y1,1);
add(x1,y2+1,-1);
add(x2+1,y1,-1);
add(x2+1,y2+1,1);
} else {
int x,y;
scanf("%d%d",&x,&y);
int ans = Query(x,y);
printf("%d\n",ans%2);
}
}
printf("\n");
}
return 0;
}
标签:clu esc rip out 数组 nes row -- element
原文地址:https://www.cnblogs.com/GoldenFingers/p/9172778.html