Submission #265395

#TimeUsernameProblemLanguageResultExecution timeMemory
265395eagle30XORanges (eJOI19_xoranges)C++14
100 / 100
960 ms8936 KiB
#include<bits/stdc++.h> using namespace std; int arr[1000000], binary1[1000000], binary2[1000000]; int n, m; void update1(int s, int k){ for(int i=s; i<=n; i+=i&-i) binary1[i]=(binary1[i]^k); } int query1(int s){ int ans=0; for(int i=s; i>=1; i-=i&-i) ans=(ans^binary1[i]); return ans; } void update2(int s, int k){ for(int i=s; i<=n; i+=i&-i) binary2[i]=(binary2[i]^k); } int query2(int s){ int ans=0; for(int i=s; i>=1; i-=i&-i) ans=(ans^binary2[i]); return ans; } int main(){ cin>>n>>m; for(int i=1; i<=n; i++){ cin>>arr[i]; if(i%2==1) update1(i, arr[i]); else update2(i, arr[i]); } for(int i=0; i<m; i++){ int hi; cin>>hi; if(hi==1){ int a, b; cin>>a>>b; if(a%2==1){ update1(a, (query1(a)^query1(a-1))); update1(a, b); } else{ update2(a, (query2(a)^query2(a-1))); update2(a, b); } } else{ int a, b; cin>>a>>b; if((a-b+1)%2==0) cout<<0<<'\n'; else if(a%2==1) cout<<(query1(b)^query1(a-1))<<'\n'; else cout<<(query2(b)^query2(a-1))<<'\n'; } } return 0; }
#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...