#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pll pair<int, int>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define ld long double
#define sz(x) static_cast<int>((x).size())
#define i5 tuple<int,int,int,int,int>
int cdiv(int a, int b){return a/b + !!(a%b);}
struct node {
int s, e, m, v;
node *l, *r;
node (int S, int E){
s=S, e=E, m=(s+e)/2, v=0;
if(s!=e){
l=new node(s, m);
r=new node(m+1, e);
}
}
int combine(int a, int b){
return a^b;
}
void upd(int S, int V){ // range add.
if(s==e){
v=V;
return;
}
if (S<=m) l->upd(S,V);
else if (S>m) r->upd(S,V);
v=combine(l->v,r->v);
}
int qry(int S,int E){
if((S==s and E==e) or s==e){
return v;
}
if(E<=m)return l->qry(S,E);
if(S>m)return r->qry(S,E);
return combine(l->qry(S,m),r->qry(m+1,E));
}
} *root[2];
signed main(){
int n,m;cin>>n>>m;
int a[n]; for(int i=0;i<n;i++)cin>>a[i];
root[0]=new node(0, n);
root[1]=new node(0, n);
for(int i=0;i<n;i++){
root[i%2]->upd(i, a[i]);
}
for(int qind=0;qind<m;qind++){
int t,a,b;cin>>t>>a>>b;
if(t==1){
a--;
root[a%2]->upd(a, b);
}
else {
a--,b--;
if((b-a+1)%2==0){
cout<<0<<'\n';
}
else {
cout<<root[a%2]->qry(a, b)<<'\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... |