#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{
if((r - l + 1)%2 == 0) cout << 0 << '\n';
else cout << tree[l&1].query(1, n, l, r, 1) << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
3 ms |
2396 KB |
Output is correct |
12 |
Correct |
3 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
2396 KB |
Output is correct |
14 |
Correct |
3 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
8140 KB |
Output is correct |
2 |
Correct |
102 ms |
7776 KB |
Output is correct |
3 |
Correct |
99 ms |
7760 KB |
Output is correct |
4 |
Correct |
100 ms |
7764 KB |
Output is correct |
5 |
Correct |
91 ms |
7912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
3 ms |
2396 KB |
Output is correct |
12 |
Correct |
3 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
2396 KB |
Output is correct |
14 |
Correct |
3 ms |
2396 KB |
Output is correct |
15 |
Correct |
102 ms |
8140 KB |
Output is correct |
16 |
Correct |
102 ms |
7776 KB |
Output is correct |
17 |
Correct |
99 ms |
7760 KB |
Output is correct |
18 |
Correct |
100 ms |
7764 KB |
Output is correct |
19 |
Correct |
91 ms |
7912 KB |
Output is correct |
20 |
Correct |
94 ms |
7252 KB |
Output is correct |
21 |
Correct |
93 ms |
7352 KB |
Output is correct |
22 |
Correct |
91 ms |
7252 KB |
Output is correct |
23 |
Correct |
91 ms |
7816 KB |
Output is correct |
24 |
Correct |
112 ms |
7784 KB |
Output is correct |