#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
using namespace std;
const int N=2e5+50;
const int inf=1e18;
const int mod=1e9+7;
int a[N];
int n;
int q;
struct segtree{
int t[4*N]={0};
void build(int v,int tl,int tr){
if(tl==tr)t[v]=a[tl];
else {
int tm=(tl+tr)/2;
build(v*2,tl,tm);
build(v*2+1,tm+1,tr);
t[v]=(t[v*2]^t[v*2+1]);
}
}
int query(int v,int tl,int tr,int l,int r){
if(tr<l||tl>r)return 0;
if(l<=tl&&tr<=r)return t[v];
int tm=(tl+tr)/2;
return (query(v*2,tl,tm,l,r)^query(v*2+1,tm+1,tr,l,r));
}
void update(int v,int tl,int tr,int index,int value){
if(tl==tr){
t[v]=value;
}
else {
int tm=(tl+tr)/2;
if(index<=tm){
update(v*2,tl,tm,index,value);
}
else {
update(v*2+1,tm+1,tr,index,value);
}
t[v]=(t[v*2]^t[v*2+1]);
}
}
};
segtree seg;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++)cin>>a[i];
seg.build(1,1,n);
while(q--){
int o;
cin>>o;
if(o==1){
int i,x;
cin>>i>>x;
seg.update(1,1,n,i,x);
}
else {
int l,r;
cin>>l>>r;
int ans=0;
for(int i=l;i<=r;i++){
ans^=seg.query(1,1,n,i,r);
}
cout<<ans;
cout<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1041 ms |
8076 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |