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 int long long
const int N = 2e5 + 7;
int t[2][N];
void upd(int ind, int val){
for(int i = ind + 1; i < N; i += i & -i){
t[ind & 1][i] ^= val;
}
}
int get(int par, int ind){
int res = 0;
for(; ind > 0; ind -= ind & -ind){
res ^= t[par][ind];
}
return res;
}
int get(int par, int l, int r){
return get(par, r) ^ get(par, l);
}
int n, q, a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
for(int i = 0; i < n; ++i){
cin >> a[i];
upd(i, a[i]);
}
while(q--){
int type;
cin >> type;
if(type == 1){
int ind, val;
cin >> ind >> val;
ind--;
upd(ind, a[ind] ^ val);
a[ind] = val;
}
if(type == 2){
int l, r;
cin >> l >> r;
l--;
r--;
int ans = 0;
if((l & 1) & (r & 1)){
ans ^= get(1, l, r + 1);
}
if(((l & 1) ^ 1) & ((r & 1) ^ 1)){
ans ^= get(0, l, r + 1);
}
cout << ans << '\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... |