# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
455329 | 2021-08-05T21:31:55 Z | kkk | XORanges (eJOI19_xoranges) | C++14 | 32 ms | 14176 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(t==0)return tree[ind][0]; else return tree[ind][1]; } long long mid=(le+ri)/2, t2; 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; if((r-l+1)%2==0) { cout<<0<<endl; return 0; } cout<<query(1,n,l,r,1,l%2)<<endl; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 14176 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |