#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mid (start+end)/2
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int dizi[200005],tese[800005],cise[800005],sum=0;
void build(int node,int start,int end){
if(start==end){
if(start%2==1)tese[node]=dizi[start];
else cise[node]=dizi[start];
return ;
}
build(node*2,start,mid),build(node*2+1,mid+1,end);
tese[node]=tese[node*2]^tese[node*2+1];
cise[node]=cise[node*2]^cise[node*2+1];
}
void querytek(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return;
if(start>=l && end<=r){
sum^=tese[node];
return ;
}
querytek(node*2,start,mid,l,r),querytek(node*2+1,mid+1,end,l,r);
}
void querycift(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return;
if(start>=l && end<=r){
sum^=cise[node];
return ;
}
querycift(node*2,start,mid,l,r),querycift(node*2+1,mid+1,end,l,r);
}
void updatetek(int node,int start,int end,int pos,int val){
if(!(start<=pos && end>=pos))return ;
if(start==end && start==pos){
tese[node]=val;
return ;
}
updatetek(node*2,start,mid,pos,val),updatetek(node*2+1,mid+1,end,pos,val);
tese[node]=tese[node*2]^tese[node*2+1];
}
void updatecift(int node,int start,int end,int pos,int val){
if(!(start<=pos && end>=pos))return ;
if(start==end && start==pos){
cise[node]=val;
return ;
}
updatecift(node*2,start,mid,pos,val),updatecift(node*2+1,mid+1,end,pos,val);
cise[node]=cise[node*2]^cise[node*2+1];
}
int32_t main(){
faster
int n,q;cin>>n>>q;
for(int i=1;i<=n;i++)cin>>dizi[i];
build(1,1,n);
while(q--){
int t,l,r;cin>>t>>l>>r;
if(t==1){
if(l%2==1)updatetek(1,1,n,l,r);
else updatecift(1,1,n,l,r);
}
else{
sum=0;
if(l%2==1)querytek(1,1,n,l,r);
else querycift(1,1,n,l,r);
cout<<sum<<'\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 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 |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
135 ms |
16924 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 |
- |