#include <bits/stdc++.h>
using namespace std;
struct FTree {
int n;
vector<int> ft;
FTree(int _n) : n(_n + 9), ft(n, 0) {}
inline int lsb(int i) {
return i & (-i);
}
void update(int i, int v) {
for (++i; i < n; i += lsb(i)) {
ft[i] ^= v;
}
}
int query(int i) {
int r = 0;
for (++i; i > 0; i -= lsb(i)) {
r ^= ft[i];
}
return r;
}
int query(int l, int r) {
return query(r) ^ query(l - 1);
}
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int &x : a) cin >> x;
vector<FTree> ft(2, FTree(n));
for (int i = 0; i < n; i++) {
ft[i % 2].update(i, a[i]);
}
while (q--) {
int t, x, y;
cin >> t >> x >> y;
if (t == 1) {
--x;
ft[x % 2].update(x, y ^ a[x]);
a[x] = y;
} else {
--x, --y;
if ((y - x) % 2 == 1) {
cout << "0\n";
} else {
cout << ft[x % 2].query(x, y) << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
508 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 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 |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
508 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
336 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 |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
596 KB |
Output is correct |
14 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
3896 KB |
Output is correct |
2 |
Correct |
66 ms |
8756 KB |
Output is correct |
3 |
Correct |
63 ms |
8660 KB |
Output is correct |
4 |
Correct |
63 ms |
8508 KB |
Output is correct |
5 |
Correct |
60 ms |
8508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
508 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
336 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 |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
596 KB |
Output is correct |
14 |
Correct |
2 ms |
596 KB |
Output is correct |
15 |
Correct |
63 ms |
3896 KB |
Output is correct |
16 |
Correct |
66 ms |
8756 KB |
Output is correct |
17 |
Correct |
63 ms |
8660 KB |
Output is correct |
18 |
Correct |
63 ms |
8508 KB |
Output is correct |
19 |
Correct |
60 ms |
8508 KB |
Output is correct |
20 |
Correct |
62 ms |
8516 KB |
Output is correct |
21 |
Correct |
63 ms |
8516 KB |
Output is correct |
22 |
Correct |
64 ms |
8356 KB |
Output is correct |
23 |
Correct |
74 ms |
8508 KB |
Output is correct |
24 |
Correct |
61 ms |
8300 KB |
Output is correct |