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;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int N = (int)3e5+10;
int n, q, x, fen[2][N];
void upd(int x, int v){
x++; int t = x%2;
for(; x < N; x+=x&-x) fen[t][x]^=v;
}
int sum(int x){
x++; int s = 0, t = x%2;
for(; x>0; x-=x&-x) s^=fen[t][x];
return s;
}
int main(){
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> x, upd(i,x);
while(q--){
int t,v,l,r; cin >> t;
if(t==1) cin >> l >> v, upd(l,sum(l)^sum(l-2)), upd(l,v);
else cin >> l >> r,cout << ((r-l+1)%2==0?0:(sum(r)^sum(l-1-(r%2==l%2)))) << "\n";
}
}
# | 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... |