Submission #491672

# Submission time Handle Problem Language Result Execution time Memory
491672 2021-12-03T18:45:22 Z uncripted XORanges (eJOI19_xoranges) C++11
38 / 100
490 ms 7932 KB
#include<bits/stdc++.h>
using namespace std;
int fl[400000];
int fk[400000];
int a[300000];	
int n,q;
void updatel(int s, int x){
	while(s<=n){
	fl[s]=fl[s]^x;	
	 s+=s&(-s);	
	}
}	
int getl(int s){
	int sum=0;
	while(s>0){
	
		sum=sum^fl[s];
		s-=s&(-s);	
	}
	return sum;
}

void updatek(int s, int x){
	while(s<=n){
	fk[s]=fk[s]^x;	
 	s+=s&(-s);	
	}
}	
int getk(int s){
	int sum=0;
	while(s>0){
	
		sum=sum^fk[s];
		s-=s&(-s);	
	}
	return sum;
}

int main(){

	cin>>n>>q;

	for(int i=1; i<=n; i++){
		cin>>a[i];
		if(i%2==0){
			updatel(i/2, a[i]);
		}else{
			updatek(i/2+1, a[i]);
		}
	}
	for(int i=0; i<q; i++){
		int x;
		cin>>x;
		if(x==1){
			int x,y;
			cin>>x>>y;
			if(x%2==0){
				updatel(x/2, y^a[x]);
			}else{
				updatek(x/2+1, y^a[x]);
			}
		}else{
			int x,y;
			cin>>x>>y;
			if((y-x+1)%2==0){
				cout<<"0"<<endl;
				continue;
			}
			if(x%2==0){
				int tot;
				x--;
				tot=getl(y/2)^(getl(x/2));
				cout<<tot<<endl;
			}else{
			
				int tot;
				
				tot=getk(y/2+1)^(getk(x/2));
				cout<<tot<<endl;
			}	
		}
	}
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 467 ms 7860 KB Output is correct
2 Correct 473 ms 7912 KB Output is correct
3 Correct 490 ms 7932 KB Output is correct
4 Correct 443 ms 7476 KB Output is correct
5 Correct 439 ms 7548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -