#include <bits/stdc++.h>
using namespace std;
int n, q, od[600010], ev[600010], c, id, va, in, st, en, f, s, enu, onu;
void update(int l, int r, int idx, int val, int node, int (&seg)[600010]) {
if(l == r) {
seg[node] = val;
return;
}
int mid = (l+r)>>1;
if(idx <= mid) update(l, mid, idx, val, node*2, seg);
else update(mid+1, r, idx, val, node*2+1, seg);
seg[node] = seg[node*2]^seg[node*2+1];
}
int query(int l, int r, int ql, int qr, int node, int (&seg)[600010]) {
if(l > qr || r < ql) return 0;
if(l >= ql && r <= qr) return seg[node];
int mid = (l+r)>>1;
return query(l, mid, ql, qr, node*2, seg)^query(mid+1, r, ql, qr, node*2+1, seg);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> q;
for(int i=1; i<=n; i++) {
cin >> in;
if(i%2) {
update(1, n, i, in, 1, od);
} else {
update(1, n, i, in, 1, ev);
}
}
while(q--) {
cin >> c;
if(c == 1) {
cin >> id >> va;
if(id%2 == 0) update(1, n, id, va, 1, ev);
else update(1, n, id, va, 1, od);
} else {
cin >> st >> en;
if((en-st)%2) cout << 0 << "\n";
else if(st%2) {
cout << query(1, n, st, en, 1, od) << "\n";
} else {
cout << query(1, n, st, en, 1, ev) << "\n";
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
120 ms |
6080 KB |
Output is correct |
2 |
Correct |
144 ms |
5972 KB |
Output is correct |
3 |
Correct |
114 ms |
5976 KB |
Output is correct |
4 |
Correct |
113 ms |
5972 KB |
Output is correct |
5 |
Correct |
102 ms |
6000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 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 |
120 ms |
6080 KB |
Output is correct |
16 |
Correct |
144 ms |
5972 KB |
Output is correct |
17 |
Correct |
114 ms |
5976 KB |
Output is correct |
18 |
Correct |
113 ms |
5972 KB |
Output is correct |
19 |
Correct |
102 ms |
6000 KB |
Output is correct |
20 |
Correct |
102 ms |
5200 KB |
Output is correct |
21 |
Correct |
105 ms |
5268 KB |
Output is correct |
22 |
Correct |
120 ms |
5536 KB |
Output is correct |
23 |
Correct |
101 ms |
5748 KB |
Output is correct |
24 |
Correct |
101 ms |
5972 KB |
Output is correct |