#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,q,k,a[N],ind,x,l,r,t[2][4*N];
void update(int u,int ind,int l,int r,int val,int p) {
if(l>ind || r<ind)
return;
if(ind<=l && r<=ind) {
t[p][u]^=val;
return;
}
int mid=(l+r)/2;
update(2*u,ind,l,mid,val,p);
update(2*u+1,ind,mid+1,r,val,p);
t[p][u]=t[p][2*u]^t[p][2*u+1];
}
int getans(int u,int start,int e,int l,int r,int p) {
if(l>e || r<start) return 0;
if(start<=l && r<=e) {
return t[p][u];
}
int mid=(l+r)/2;
return getans(2*u,start,e,l,mid,p)^
getans(2*u+1,start,e,mid+1,r,p);
}
int main() {
cin>>n>>q;
for(int i=1; i<=n; i++) {
cin>>a[i];
if(i%2==1) update(1,i,1,n,a[i],1);
else update(1,i,1,n,a[i],0);
}
for(k=1; k<=q; k++) {
cin>>x;
if(x==1) {
cin>>ind>>x;
if(ind%2==0) update(1,ind,1,n,a[ind]^x,0);
else update(1,ind,1,n,a[ind]^x,1);
a[ind]=x;
} else {
cin>>l>>r;
if((r-l+1)%2==0) cout<<0<<" ";
else {
cout<<getans(1,l,r,1,n,r%2)<<" ";
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
17 ms |
460 KB |
Output is correct |
12 |
Correct |
13 ms |
476 KB |
Output is correct |
13 |
Correct |
16 ms |
472 KB |
Output is correct |
14 |
Correct |
16 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
718 ms |
6468 KB |
Output is correct |
2 |
Correct |
734 ms |
6336 KB |
Output is correct |
3 |
Correct |
722 ms |
6340 KB |
Output is correct |
4 |
Correct |
679 ms |
6396 KB |
Output is correct |
5 |
Correct |
678 ms |
6372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
17 ms |
460 KB |
Output is correct |
12 |
Correct |
13 ms |
476 KB |
Output is correct |
13 |
Correct |
16 ms |
472 KB |
Output is correct |
14 |
Correct |
16 ms |
460 KB |
Output is correct |
15 |
Correct |
718 ms |
6468 KB |
Output is correct |
16 |
Correct |
734 ms |
6336 KB |
Output is correct |
17 |
Correct |
722 ms |
6340 KB |
Output is correct |
18 |
Correct |
679 ms |
6396 KB |
Output is correct |
19 |
Correct |
678 ms |
6372 KB |
Output is correct |
20 |
Correct |
562 ms |
5744 KB |
Output is correct |
21 |
Correct |
612 ms |
5844 KB |
Output is correct |
22 |
Correct |
580 ms |
5776 KB |
Output is correct |
23 |
Correct |
677 ms |
6300 KB |
Output is correct |
24 |
Correct |
666 ms |
6212 KB |
Output is correct |