# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
455327 | 2021-08-05T21:18:57 Z | kkk | XORanges (eJOI19_xoranges) | C++14 | 247 ms | 16260 KB |
#include<bits/stdc++.h> #define endl '\n' using namespace std; long long a[1000003],tree[4000000][3]; void build_tree(long long l,long long r,long long ind) { if(l==r) { if(l%2==0)tree[ind][0]=a[l]; else tree[ind][1]=a[l]; return; } long long mid=(l+r)/2; build_tree(l,mid,2*ind); build_tree(mid+1,r,2*ind+1); tree[ind][0]=(tree[2*ind][0]^tree[2*ind+1][0]); tree[ind][1]=(tree[2*ind][1]^tree[2*ind+1][1]); } void update(long long l,long long r,long long pos,long long val,long long ind) { if(pos>r || pos<l)return; if(l==r) { if(l%2==0)tree[ind][0]=val; else tree[ind][1]=val; return; } long long mid=(l+r)/2; update(l,mid,pos,val,2*ind); update(mid+1,r,pos,val,2*ind+1); tree[ind][0]=(tree[2*ind][0]^tree[2*ind+1][0]); tree[ind][1]=(tree[2*ind][1]^tree[2*ind+1][1]); } long long query(long long le,long long ri,long long l,long long r,long long ind,int t) { if(le>r || ri<l)return 0; if(l<=le && ri<=r) { if(le%2==0)return tree[ind][0]; else return tree[ind][1]; } long long mid=(le+ri)/2, t2; // if((mid-le+1)%2==0)t2=t; // else t2=1-t; return (query(le,mid,l,r,2*ind,t)^query(mid+1,ri,l,r,2*ind+1,t)); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n,m,q,j,i,b,ans=0,t,l,r; cin>>n>>q; for(i=1;i<=n;i++) { cin>>a[i]; } build_tree(1,n,1); for(i=0;i<q;i++) { cin>>t; if(t==1) { cin>>l>>r; update(1,n,l,r,1); } else { cin>>l>>r; cout<<query(1,n,l,r,1,l%2)<<endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 247 ms | 16260 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |