#include<bits/stdc++.h>
using namespace std;
struct SegmentTree{
int seg[1000100] = {0};
void update(int l, int r, int idx, int val, int node){
if(l == r){
seg[node] = val;
return;
}
int mid = (l + r) >> 1;
if(idx <= mid) update(l, mid, idx, val, node*2);
else update(mid+1, r, idx,val, node*2+1);
seg[node] = seg[node*2]^seg[node*2+1];
}
int query(int l, int r, int ql, int qr, int node){
if(r < ql || l > qr) return 0;
if(l >= ql && r <= qr) return seg[node];
int mid = (l + r) >> 1;
return query(l, mid, ql, qr, node*2)^query(mid+1, r, ql, qr, node*2+1);
}
};
SegmentTree tree[2];
int n, q, a;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> q;
for(int i = 1; i<=n; ++i) cin >> a, tree[i&1].update(1, n, i, a, 1);
while(q--){
int t, l, r; cin >> t >> l >> r;
if(t == 1) tree[l&1].update(1, n, l, r, 1);
else cout << tree[l&1].query(1, n, l, r, 1) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
13396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |