#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, q;
int a[maxn], fenp[maxn], fennp[maxn];
void add (int x, int val) {
if (x & 1) {
for (; x < maxn; x += x & -x) {
fennp[x] ^= val;
}
}
else {
for (; x < maxn; x += x & -x) {
fenp[x] ^= val;
}
}
}
int query (int x) {
int out = 0;
if (x & 1) {
for (; x > 0; x -= x & -x) {
out ^= fennp[x];
}
}
else {
for (; x > 0; x -= x & -x) {
out ^= fenp[x];
}
}
return out;
}
int main () {
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> a[i];
add(i+1, a[i]);
}
for (int i = 0; i < q; i++) {
int ot; cin >> ot; --ot;
if (ot) {
int a, b;
cin >> a >> b;
if ((b - a) & 1) cout << "0\n";
else {
b -= (b - a) & 1;
cout << (query(b) ^ query(a - 2)) << "\n";
}
}
else {
int x, val;
cin >> x >> val;
add(x, a[x-1]);
add(x, val);
a[x-1] = val;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
312 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 |
320 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 |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
312 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 |
320 KB |
Output is correct |
11 |
Correct |
11 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
556 KB |
Output is correct |
13 |
Correct |
13 ms |
448 KB |
Output is correct |
14 |
Correct |
15 ms |
548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
481 ms |
8560 KB |
Output is correct |
2 |
Correct |
470 ms |
8588 KB |
Output is correct |
3 |
Correct |
548 ms |
8676 KB |
Output is correct |
4 |
Correct |
483 ms |
8320 KB |
Output is correct |
5 |
Correct |
453 ms |
8268 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 |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
312 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 |
320 KB |
Output is correct |
11 |
Correct |
11 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
556 KB |
Output is correct |
13 |
Correct |
13 ms |
448 KB |
Output is correct |
14 |
Correct |
15 ms |
548 KB |
Output is correct |
15 |
Correct |
481 ms |
8560 KB |
Output is correct |
16 |
Correct |
470 ms |
8588 KB |
Output is correct |
17 |
Correct |
548 ms |
8676 KB |
Output is correct |
18 |
Correct |
483 ms |
8320 KB |
Output is correct |
19 |
Correct |
453 ms |
8268 KB |
Output is correct |
20 |
Correct |
375 ms |
8508 KB |
Output is correct |
21 |
Correct |
373 ms |
8408 KB |
Output is correct |
22 |
Correct |
363 ms |
8396 KB |
Output is correct |
23 |
Correct |
450 ms |
8252 KB |
Output is correct |
24 |
Correct |
501 ms |
8336 KB |
Output is correct |