#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 2e5 + 5;
struct Fenwick {
int s[N];
void upd(int i, int x) {
for (; i < N; i += i & -i) {
s[i] ^= x;
}
}
int qry(int i) {
int res = 0;
for (; i; i -= i & -i) {
res ^= s[i];
}
return res;
}
int qry(int l, int r) {
return qry(r) ^ qry(l - 1);
}
} ft[2];
int n, q;
int a[N];
int qry(int l, int r) {
if (l % 2 != r % 2) {
return 0;
}
return ft[l & 1].qry((l + 1) / 2, (r + 1) / 2);
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> q;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
ft[i & 1].upd((i + 1) / 2, a[i]);
}
while (q--) {
int type; cin >> type;
if (type == 1) {
int i, j; cin >> i >> j;
ft[i & 1].upd((i + 1) / 2, j ^ a[i]);
a[i] = j;
} else {
int l, r; cin >> l >> r;
cout << qry(l, r) << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
8016 KB |
Output is correct |
2 |
Correct |
59 ms |
8024 KB |
Output is correct |
3 |
Correct |
68 ms |
7884 KB |
Output is correct |
4 |
Correct |
58 ms |
7512 KB |
Output is correct |
5 |
Correct |
57 ms |
7764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
60 ms |
8016 KB |
Output is correct |
16 |
Correct |
59 ms |
8024 KB |
Output is correct |
17 |
Correct |
68 ms |
7884 KB |
Output is correct |
18 |
Correct |
58 ms |
7512 KB |
Output is correct |
19 |
Correct |
57 ms |
7764 KB |
Output is correct |
20 |
Correct |
57 ms |
7760 KB |
Output is correct |
21 |
Correct |
63 ms |
7760 KB |
Output is correct |
22 |
Correct |
58 ms |
7764 KB |
Output is correct |
23 |
Correct |
56 ms |
7756 KB |
Output is correct |
24 |
Correct |
63 ms |
7504 KB |
Output is correct |