Submission #455332

#TimeUsernameProblemLanguageResultExecution timeMemory
455332daisyXORanges (eJOI19_xoranges)C++17
100 / 100
176 ms6516 KiB
#include<iostream> #define endl '\n' using namespace std; int tree[800005][2],m[2000005]; void build(int node,int l,int r) { if(l==r) { tree[node][l%2]=m[l]; return; } int mid=(l+r)/2; build(2*node,l,mid); build(2*node+1,mid+1,r); tree[node][0]=(tree[2*node][0]^tree[2*node+1][0]); tree[node][1]=(tree[2*node][1]^tree[2*node+1][1]); } void update(int node,int l,int r,int val,int p) { if(r<p || l>p) return; if(l==r) { tree[node][l%2]=val; return; } int mid=(l+r)/2; update(2*node,l,mid,val,p); update(2*node+1,mid+1,r,val,p); tree[node][0]=tree[2*node][0]^tree[2*node+1][0]; tree[node][1]=tree[2*node][1]^tree[2*node+1][1]; } int query(int node,int l,int r,int le, int ri, int t) { if(l>ri || r<le) return 0; if(l>=le && r<=ri) return tree[node][t%2]; int mid=(l+r)/2; return (query(2*node,l,mid,le,ri,t)^query(2*node+1,mid+1,r,le,ri,t)); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q,x,y,c; cin>>n>>q; for(int i=1;i<=n;i++) cin>>m[i]; build(1,1,n); for(int i=0;i<q;i++) { cin>>c>>x>>y; if(c==1) { update(1,1,n,y,x); } if(c==2) { if((x-y+1)%2==0) cout<<0<<endl; else cout<<query(1,1,n,x,y,x%2)<<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...