#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void update(ll l,ll r,ll u,ll ind,ll val,vector<ll>&seg){
if(l==r && l==ind){
seg[u]=val;
return;
}
ll mid=(l+r)/2;
if(ind<=mid) update(l,mid,u*2+1,ind,val,seg);
else update(mid+1,r,u*2+2,ind,val,seg);
seg[u]=seg[u*2+1]^seg[u*2+2];
}
ll get(ll l,ll r,ll u,ll lx,ll rx,vector<ll>&seg){
if(l>=lx && r<=rx){
return seg[u];
}
if(l>rx||r<lx){
return 0;
}
ll mid = (l+r)/2;
return get(l,mid,u*2+1,lx,rx,seg)^get(mid+1,r,u*2+2,lx,rx,seg);
}
void solve(){
ll n,q;
cin>>n>>q;
vector<ll>segk,segz;
ll s = 1;
while(s<=n) s*=2;
segk = segz = vector<ll>(s*2);
vector<ll>v(n);
for(ll i = 0;i<n;i++){
cin>>v[i];
if(i%2==0) update(0,s-1,0,i,v[i],segz);
else update(0,s-1,0,i,v[i],segk);
}
while(q--){
ll type;
cin>>type;
if(type==1){
ll ind,x;
cin>>ind>>x;
--ind;
if(ind%2==0) update(0,s-1,0,ind,x,segz);
else update(0,s-1,0,ind,x,segk);
}
else{
ll l,r;
cin>>l>>r;
--l,--r;
if(l%2==0 && (r-l+1)%2==1) cout<<get(0,s-1,0,l,r,segz)<<endl;
else if(l%2==1 && (r-l+1)==1) cout<<get(0,s-1,0,l,r,segk)<<endl;
else if(l%2==0 && (r-l+1)%2==0) cout<<get(0,s-1,0,l,r,segk)<<endl;
else if(l%2==1 && (r-l+1)%2==0) cout<<get(0,s-1,0,l,r,segz)<<endl;
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
// ll t;cin>>t;while(t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
337 ms |
11496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |