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>
using namespace std;
struct Seg {
int val = 0;
int l,r,mid;
Seg *ls, *rs;
Seg(int l, int r): l(l), r(r), mid((l+r)/2) {
if(l + 1 < r) {
ls = new Seg(l, mid);
rs = new Seg(mid, r);
}
}
int query(int a, int b) {
if(a >= r || b <= l) { return 0; }
if(a <= l && b >= r) { return val; }
return (ls->query(a,b))^(rs->query(a,b));
}
void update(int i, int x) {
if(l + 1 == r) {
val = x;
return;
}
if(i < mid) { ls->update(i,x); } else { rs->update(i,x); }
val = (ls->val)^(rs->val);
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,q,x,y,t;
cin >> n >> q;
Seg odd(0, (int)((n+1)/2));
Seg even(0, n/2);
for(int i = 0; i < n / 2; i ++) {
cin >> x;
odd.update(i, x);
cin >> x;
even.update(i, x);
}
if(n%2) {
cin >> x;
odd.update((n-1)/2, x);
}
for(int i = 0; i < q; i ++) {
cin >> t >> x >> y; x--;
if(t == 1) {
if(x%2) {
even.update(x/2, y);
} else {
odd.update(x/2, y);
}
} else {
if((y - x)%2) {
if(x%2) {
cout << even.query(x/2,(y+1)/2) << endl;
} else {
cout << odd.query(x/2,(y+1)/2) << endl;
}
} else {
cout << 0 << endl;
}
}
}
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... |