树状数组
1 #include<bits/stdc++.h> 2 using namespace std; 3 int x,y,c[200005]; 4 char str[20]; 5 int inline read(){ 6 int x=0,f=1; 7 char ch=getchar(); 8 while(ch<'0'||ch>'9') 9 ch=getchar(); 10 while(ch>='0'&&ch<='9'){ 11 x=x*10+ch-'0'; 12 ch=getchar(); 13 } 14 return x*f; 15 } 16 inline void add(int x,int y){ 17 while (x<=20005){ 18 c[x]^=y; 19 x+=x&-x; 20 } 21 return; 22 } 23 inline int ask(int x){ 24 int sum=0; 25 while (x){ 26 sum^=c[x]; 27 x-=x&-x; 28 } 29 return sum; 30 } 31 int main(){ 32 while (~scanf("%s",str)){ 33 if (str[0]=='A'||str[0]=='R'){ 34 x=read(); 35 add(x,x); 36 } 37 else if (str[0]=='X'){ 38 x=read(); 39 y=read(); 40 if (x>y) 41 printf("0 "); 42 else 43 printf("%d ",ask(x-1)^ask(y)); 44 } 45 else return 0; 46 scanf(" "); 47 } 48 return 0; 49 }