#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[200005],s[2][800020];
void build(int node,int l,int r,int t){
if(l==r){
s[t][node]=arr[(t==0?l*2-1:l*2)];
return;
}
int mid=(l+r)/2;
build(node*2,l,mid,t);
build(node*2+1,mid+1,r,t);
s[t][node]=(s[t][node*2]^s[t][node*2+1]);
return;
}
void update(int node,int l,int r,int x,int y,int t){
if(l>x || r<x)return;
if(l==r){
s[t][node]=y;
return;
}
int mid=(l+r)/2;
update(node*2,l,mid,x,y,t);
update(node*2+1,mid+1,r,x,y,t);
s[t][node]=(s[t][node*2]^s[t][node*2+1]);
return;
}
int query(int node,int l,int r,int x,int y,int t){
if(l>y || r<x)return 0;
if(l>=x && r<=y)return s[t][node];
int mid=(l+r)/2;
return (query(node*2,l,mid,x,y,t)^query(node*2+1,mid+1,r,x,y,t));
}
int32_t main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)cin>>arr[i];
int o=(n+1)/2,e=n/2;
build(1,1,o,0);
build(1,1,e,1);
while(q--){
int a,b,c;
cin>>a>>b>>c;
if(a==1){
if(b%2){
update(1,1,o,(b+1)/2,c,0);
}
else{
update(1,1,e,b/2,c,1);
}
}
else{
if(b%2){
cout<<query(1,1,o,(b+1)/2,(c+1)/2,0)<<endl;
}
else{
cout<<query(1,1,e,b/2,c/2,1)<<endl;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
436 ms |
12800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |