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 N 200005
#define int long long
using namespace std;
int t[4*N][2];
int arr[N];
void upd(int v,int tl,int tr,int pos,int val){
if(tl == tr){
t[v][pos%2] = val;
}
else{
int tm = (tl+tr)/2;
if(pos <= tm)
upd(v*2,tl,tm,pos,val);
else upd(v*2+1,tm+1,tr,pos,val);
t[v][0] = t[v*2][0] ^ t[v*2+1][0];
t[v][1] = t[v*2][1] ^ t[v*2+1][1];
}
}
int get(int v,int tl,int tr,int l,int r,int idx){
if(tr < l || r <tl){
return 0;
}
if(l <= tl && tr <= r){
return t[v][idx];
}
int tm = (tl+tr)/2;
return get(v*2,tl,tm,l,r,idx)^get(v*2+1,tm+1,tr,l,r,idx);
}
void solve(){
int n,q;
cin >> n >> q;
for(int i=1;i<=n;i++){
cin >> arr[i];
upd(1,1,n,i,arr[i]);
}
while(q--){
int type;
cin >> type;
if(type == 1){
int pos,val;
cin >> pos >> val;
upd(1,1,n,pos,val);
}
if(type == 2){
int l,r;
cin >> l >> r;
if((r-l)%2){
cout << 0 << "\n";
continue;
}
cout << get(1,1,n,l,r,l%2) << "\n";
}
}
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# | 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... |