#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, q, st[5][N*4];
vector <int> a;
int bld(int nd, int l, int r, bool z){
if(l == r) return st[z][nd] = a[l*2-z];
int md = (l + r) / 2;
return st[z][nd] = (bld(nd*2,l,md,z) ^ bld(nd*2+1,md+1,r,z));
}
int upd(int nd, int l, int r, int ind, int vl, bool z){
if(l > ind or r < ind) return st[z][nd];
if(l == r) return st[z][nd] = vl;
int md = (l + r) / 2;
return st[z][nd] = (upd(nd*2,l,md,ind,vl,z) ^ upd(nd*2+1,md+1,r,ind,vl,z));
}
int fnd(int nd, int l, int r, int x, int y, bool z){
if(l > y or r < x) return 0;
if(l >= x and r <= y) return st[z][nd];
int md = (l + r) / 2;
return (fnd(nd*2,l,md,x,y,z) ^ fnd(nd*2+1,md+1,r,x,y,z));
}
int main(){
cin >> n >> q;
a.assign(n+1,0);
for(int i = 1; i <= n; i++){
cin >> a[i];
}
if(n > 1) bld(1,1,n/2,0);
bld(1,1,(n+1)/2,1);
while(q--){
int t, l, r;
cin >> t >> l >> r;
int x = (l%2);
if(t == 1){
upd(1,1,(n+x)/2,(l+x)/2,r,x);
}
else {
if((r-l+1) % 2 == 0){
l++;
x = (l%2);
}
cout << fnd(1,1,(n+x)/2,(l+x)/2,(r+x)/2,x) << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
433 ms |
9668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |