#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
struct Fenwick {
int val[N] = {0};
void add(int i, int x) {
for (++i; i < N; i += i & -i) {
val[i] ^= x;
}
}
int get(int i) {
int ret = 0;
for (++i; i; i -= i & -i) {
ret ^= val[i];
}
return ret;
}
int get(int l, int r) {
if (l) return get(r) ^ get(l - 1);
return get(r);
}
} fen[2];
int n, q, a[N];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
for (int i = 0; i < n; ++i) {
cin >> a[i];
fen[i & 1].add(i >> 1, a[i]);
}
while (q--) {
int t, x, y;
cin >> t >> x >> y;
if (t == 1) {
--x;
fen[x & 1].add(x >> 1, a[x] ^ y);
a[x] = y;
} else {
--x, --y;
if ((x - y) & 1) {
cout << "0\n";
} else {
cout << fen[y & 1].get(x >> 1, y >> 1) << "\n";
}
}
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |