Submission #592250

#TimeUsernameProblemLanguageResultExecution timeMemory
592250IwanttobreakfreeXORanges (eJOI19_xoranges)C++98
0 / 100
572 ms6392 KiB
#include <iostream> #include <vector> using namespace std; void build(int n,int l,int r,vector<int>& t,vector<int>& li){ if(l==r)t[n]=li[l]; else{ int mid=(r+l)/2; build(n<<1,l,mid,t,li); build((n<<1)+1,mid+1,r,t,li); t[n]=t[n<<1]^t[(n<<1)+1]; } } void p_upd(int n,int l,int r,vector<int>& t,int x,int y){ if(l>x||r<x)return; if(l==r&&l==x)t[n]=y; else{ int mid=(r+l)/2; p_upd(n<<1,l,mid,t,x,y); p_upd((n<<1)+1,mid+1,r,t,x,y); t[n]=t[n<<1]^t[(n<<1)+1]; } } int val(int n,int l,int r,vector<int>& t,int x,int y){ if(l>y||r<x)return 0; if(l>=x&&r<=y)return t[n]; else{ int mid=(r+l)/2; int valls=val(n<<1,l,mid,t,x,y); int valrs=val((n<<1)+1,mid+1,r,t,x,y); return valls^valrs; } } int main(){ int n,q,t,x,y; cin>>n>>q; vector<int> l1(n/2),l2(n-n/2); vector<int> t1(2*n),t2(2*(n-n/2)); for(int i=0;i<n;i++){ cin>>x; if(i&1)l1[i/2]=x; else l2[i/2]=x; } //for(int i=0;i<l2.size();i++)cout<<l2[i]<<' '; if(n>1)build(1,0,n/2-1,t1,l1); build(1,0,n-n/2-1,t2,l2); while(q--){ cin>>t>>x>>y; if(t==1){ if(x&1)p_upd(1,0,n-n/2-1,t2,(x-1)/2,y); else p_upd(1,0,n/2-1,t1,(x-1)/2,y); }else{ if((y-x)&1)cout<<0<<'\n'; else{ if(x&1)cout<<val(1,0,n-n/2-1,t2,(x-1)/2,(y-1)/2); else cout<<val(1,0,n/2-1,t1,(x-1)/2,(y-1)/2); cout<<'\n'; } } } }
#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...