This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'
using namespace std;
const int MOD = 1e9 + 7;
const int N = 2 * 1e5 + 1;
int n, q, a[N], t[4 * N], ty;
void build(int v, int tl, int tr) {
if (tl == tr) {
t[v] = a[tl];
return;
}
int tm = (tl + tr) / 2;
build(v*2, tl, tm); build(v*2+1, tm+1, tr);
t[v] = t[v*2] ^ t[v*2+1];
}
int solve(int v, int tl, int tr, int l, int r) {
if (l > r) return 0;
if (tl == l and tr == r)
return t[v];
int tm = (tl + tr) / 2;
return solve(v*2, tl, tm, l, min(tm, r)) ^ solve(v*2+1, tm+1, tr, max(tm+1, tl), tr);
}
void update(int v, int tl, int tr, int pos, int new_value) {
if (tl == tr) {
t[v] = new_value;
return;
}
int tm = (tl + tr) / 2;
if (pos <= tm) update(v*2, tl, tm, pos, new_value);
else update(v*2+1, tm+1, tr, pos, new_value);
t[v] = t[v*2] ^ t[v*2+1];
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
build(1, 0, n - 1);
while(q--) {
cin >> ty;
if (ty & 1) {
int l, r;
cin >> l >> r;
update(1, 0, n - 1, --l, r);
} else {
int l, r;
cin >> l >> r;
cout << solve(1, 0, n-1, --l, --r) << endl;
}
}
}
# | 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... |