#include <bits/stdc++.h>
using namespace std;
const int BIT = 18;
const int N = (1 << BIT);
int n, q;
int t[2][2 * N] = { 0 };
void update(int x, int pos, int val){
t[x][pos] = val; pos /= 2;
while (pos > 0){
t[x][pos] = (t[x][2 * pos] ^ t[x][2 * pos + 1]); pos /= 2;
}
}
int query(int x, int u, int l, int r, int ql, int qr){
if (ql > r || qr < l)
return 0;
if (ql >= l && qr <= r)
return t[u][x];
int mid = (ql + qr) / 2;
return (query(2 * x, u, l, r, ql, mid) ^ query(2 * x + 1, u, l, r, mid + 1, qr));
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int i = 0; i < n; ++i){
int x; cin >> x;
update(i & 1, N + i, x);
}
for (int i = 0; i < q; ++i){
int u; cin >> u;
if (u == 1){
int pos, x; cin >> pos >> x;
--pos; update(pos & 1, N + pos, x);
}
else{
int l, r; cin >> l >> r; --l; --r;
if ((r - l) & 1)
cout << 0;
else cout << query(1, l & 1, l + 1, r + 1, 1, N);
cout << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
600 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
121 ms |
9548 KB |
Output is correct |
2 |
Correct |
119 ms |
9520 KB |
Output is correct |
3 |
Correct |
140 ms |
9476 KB |
Output is correct |
4 |
Correct |
111 ms |
9108 KB |
Output is correct |
5 |
Correct |
110 ms |
9144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
600 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
121 ms |
9548 KB |
Output is correct |
16 |
Correct |
119 ms |
9520 KB |
Output is correct |
17 |
Correct |
140 ms |
9476 KB |
Output is correct |
18 |
Correct |
111 ms |
9108 KB |
Output is correct |
19 |
Correct |
110 ms |
9144 KB |
Output is correct |
20 |
Correct |
104 ms |
9268 KB |
Output is correct |
21 |
Correct |
110 ms |
9408 KB |
Output is correct |
22 |
Correct |
106 ms |
9396 KB |
Output is correct |
23 |
Correct |
108 ms |
9156 KB |
Output is correct |
24 |
Correct |
110 ms |
9144 KB |
Output is correct |