Submission #491674

#TimeUsernameProblemLanguageResultExecution timeMemory
491674uncriptedXORanges (eJOI19_xoranges)C++11
38 / 100
519 ms4692 KiB
#include<bits/stdc++.h>
using namespace std;
long long fl[400000];
long long fk[400000];
long long a[300000];	
long long n,q;
void updatel(long long s, long long x){
	while(s<=n){
	fl[s]=fl[s]^x;	
	 s+=s&(-s);	
	}
}	
long long getl(long long s){
	long long sum=0;
	while(s>0){
	
		sum=sum^fl[s];
		s-=s&(-s);	
	}
	return sum;
}

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

int main(){

	cin>>n>>q;

	for(long long 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(long long i=0; i<q; i++){
		long long x;
		cin>>x;
		if(x==1){
			long long x,y;
			cin>>x>>y;
			if(x%2==0){
				updatel(x/2, y^a[x]);
			}else{
				updatek(x/2+1, y^a[x]);
			}
		}else{
			long long x,y;
			cin>>x>>y;
			if((y-x+1)%2==0){
				cout<<"0"<<endl;
				continue;
			}
			if(x%2==0){
				long long tot;
				x--;
				tot=getl(y/2)^(getl(x/2));
				cout<<tot<<endl;
			}else{
			
				long long tot;
				
				tot=getk(y/2+1)^(getk(x/2));
				cout<<tot<<endl;
			}	
		}
	}
	
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...