#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 210;
int n, q, arr[N], qt, t1[5*N], t2[5*N], len;
void init(int l, int r, int k){
if(l==r){
t1[k]=t2[k]=0;
if(l&1) t1[k]=arr[l];
else t2[k]=arr[l];
return;
}
int mid = (l+r)/2;
init(l, mid, 2*k);
init(mid+1, r, 2*k+1);
t1[k] = t1[2*k]^t1[2*k+1];
t2[k] = t2[2*k]^t2[2*k+1];
}
void update(int l, int r, int p, int val, int k){
if(l > p || r < p) return;
if(l == r){
if(l&1) t1[k] = val;
else t2[k] = val;
return;
}int mid = (l+r)/2;
update(l, mid, p, val, 2*k);
update(mid+1, r, p, val, 2*k+1);
t1[k] = t1[2*k]^t1[2*k+1];
t2[k] = t2[2*k]^t2[2*k+1];
}
int ans(int l, int r, int ql, int qr, int k){
if(l > qr || r < ql) return 0;
if(l <= ql && r <= qr){
return (ql & 1 ? t1[k] : t2[k]);
}
int mid = (l+r)/2;
return ans(l, mid, ql, qr, 2*k) ^ ans(mid+1, r, ql, qr, 2*k+1);
}
int main(){
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> arr[i];
init(1, n, 1);
while(q--){
int l, r;
cin >> qt >> l >> r;
if(qt == 1){
update(1, n, l, r, 1);
}
else
cout << ans(1, n, l, r, 1) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
304 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |