#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define pb push_back
#define N 2000005
int seg[N*4],segment[N*4], ama[N],ancak[N];
inline void buid(int x,int l,int r){
if(l>r)return;
if(l==r){seg[x]=ama[l];return;}
int m=(l+r)/2;
buid(x*2,l,m);buid(x*2+1,m+1,r);
seg[x]=seg[x*2]^seg[x*2+1];
}
inline void up(int x,int l,int r,int hedef,int val){
if(l>r||l>hedef||r<hedef)return;
if(l==r){seg[x]=val;return;}
int m=(l+r)/2;
up(x*2,l,m,hedef,val);up(x*2+1,m+1,r,hedef,val);
seg[x]=seg[x*2]^seg[x*2+1];
}
inline int qu(int x,int l,int r,int s,int e){
if(l>r||s>r||e<l)return 0;
if(s<=l&&r<=e)return seg[x];
int m=(l+r)/2;
return qu(x*2,l,m,s,e)^qu(x*2+1,m+1,r,s,e);
}
inline void bui(int x,int l,int r){
if(l>r)return;
if(l==r){segment[x]=ancak[l];return;}
int m=(l+r)/2;
bui(x*2,l,m);bui(x*2+1,m+1,r);
segment[x]=segment[x*2]^segment[x*2+1];
}
inline void update(int x,int l,int r,int hedef,int val){
if(l>r||l>hedef||r<hedef)return;
if(l==r){segment[x]=val;return;}
int m=(l+r)/2;
update(x*2,l,m,hedef,val);update(x*2+1,m+1,r,hedef,val);
segment[x]=segment[x*2]^segment[x*2+1];
}
inline int quary(int x,int l,int r,int s,int e){
if(l>r||s>r||e<l)return 0;
if(s<=l&&r<=e)return segment[x];
int m=(l+r)/2;
return quary(x*2,l,m,s,e)^quary(x*2+1,m+1,r,s,e);
}
int main(){
lalala;
int n,q;cin>>n>>q;
int ii=1,jj=1;
for(int i=1;i<=n;i++){
if(i%2){cin>>ama[ii];ii++;}
else {cin>>ancak[jj];jj++;}
}
buid(1,1,ii);bui(1,1,jj);
while(q--){
int yes,x,y;cin>>yes>>x>>y;
if(yes==1){
if(x%2){
up(1,1,ii,(x+1)/2,y);
}
else update(1,1,jj,(x+1)/2,y);
continue;
}
if((y-x)%2){cout<<0<<endl;continue;}
if(x%2) cout<<qu(1,1,ii,(x+1)/2,(y+1)/2)<<endl;
else cout<<quary(1,1,jj,(x+1)/2,(y+1)/2)<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
472 KB |
Output is correct |
12 |
Correct |
5 ms |
468 KB |
Output is correct |
13 |
Correct |
9 ms |
556 KB |
Output is correct |
14 |
Correct |
7 ms |
548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
288 ms |
6432 KB |
Output is correct |
2 |
Correct |
287 ms |
9136 KB |
Output is correct |
3 |
Correct |
335 ms |
9112 KB |
Output is correct |
4 |
Correct |
286 ms |
8804 KB |
Output is correct |
5 |
Correct |
276 ms |
8760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
5 ms |
472 KB |
Output is correct |
12 |
Correct |
5 ms |
468 KB |
Output is correct |
13 |
Correct |
9 ms |
556 KB |
Output is correct |
14 |
Correct |
7 ms |
548 KB |
Output is correct |
15 |
Correct |
288 ms |
6432 KB |
Output is correct |
16 |
Correct |
287 ms |
9136 KB |
Output is correct |
17 |
Correct |
335 ms |
9112 KB |
Output is correct |
18 |
Correct |
286 ms |
8804 KB |
Output is correct |
19 |
Correct |
276 ms |
8760 KB |
Output is correct |
20 |
Correct |
189 ms |
8848 KB |
Output is correct |
21 |
Correct |
184 ms |
8828 KB |
Output is correct |
22 |
Correct |
203 ms |
8888 KB |
Output is correct |
23 |
Correct |
263 ms |
8808 KB |
Output is correct |
24 |
Correct |
272 ms |
8848 KB |
Output is correct |