#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);
}
}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 (r - l + 1)&1 ? cout << tree[l&1].query(1, n, l, r, 1) << '\n' : cout << 0 << '\n';
}
}
# |
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 |
0 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 |
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 |
0 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 |
2668 KB |
Output is correct |
12 |
Correct |
3 ms |
2652 KB |
Output is correct |
13 |
Correct |
3 ms |
2524 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
12028 KB |
Output is correct |
2 |
Correct |
101 ms |
11600 KB |
Output is correct |
3 |
Correct |
100 ms |
11604 KB |
Output is correct |
4 |
Correct |
95 ms |
11932 KB |
Output is correct |
5 |
Correct |
94 ms |
11600 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 |
0 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 |
2668 KB |
Output is correct |
12 |
Correct |
3 ms |
2652 KB |
Output is correct |
13 |
Correct |
3 ms |
2524 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
15 |
Correct |
110 ms |
12028 KB |
Output is correct |
16 |
Correct |
101 ms |
11600 KB |
Output is correct |
17 |
Correct |
100 ms |
11604 KB |
Output is correct |
18 |
Correct |
95 ms |
11932 KB |
Output is correct |
19 |
Correct |
94 ms |
11600 KB |
Output is correct |
20 |
Correct |
97 ms |
11600 KB |
Output is correct |
21 |
Correct |
95 ms |
11524 KB |
Output is correct |
22 |
Correct |
107 ms |
11624 KB |
Output is correct |
23 |
Correct |
92 ms |
11604 KB |
Output is correct |
24 |
Correct |
101 ms |
11648 KB |
Output is correct |