-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLOJ-1080.cpp
46 lines (46 loc) · 986 Bytes
/
LOJ-1080.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
bool arr[100010];
int tree[100010],limit;
void update(int i,int v) {
while(i<=limit) {
tree[i]+=v;
i+=(i&(-i));
}
}
int read(int i) {
int sum=0;
while(i>0) {
sum+=tree[i];
i-=(i&(-i));
}
return sum;
}
int main() {
char s[100010];
int t;
scanf("%d",&t);
getchar();
for(int z=1; z<=t; z++) {
memset(arr,0,sizeof(arr));
memset(tree,0,sizeof(tree));
scanf("%s",s);
limit=strlen(s);
for(int i=0; s[i]; i++)arr[i+1]=(s[i]-48);
int k;
scanf("%d",&k);
printf("Case %d:\n",z);
while(k--) {
char c,c1;
int a,b;
getchar();
scanf("%c%c%d",&c,&c1,&a);
if(c=='I') {
scanf("%d",&b);
update(a,1);
update(b+1,-1);
} else printf("%d\n",(arr[a]^(read(a)&1)));
}
}
return 0;
}