#include<iostream>
#define endl '\n'
using namespace std;
int tree[800005][2],m[2000005];
void build(int node,int l,int r)
{
if(l==r)
{
if(l%2==0)
tree[node][0]=m[l];
else
tree[node][1]=m[l];
return;
}
int mid=(l+r)/2;
build(2*node,l,mid);
build(2*node+1,mid+1,r);
tree[node][0]=tree[2*node][0]^tree[2*node+1][0];
tree[node][1]=tree[2*node][1]^tree[2*node+1][1];
}
void update(int node,int l,int r,int val,int p)
{
if(r<p || l>p) return;
if(l==r)
{
tree[node][l%2]=val;
return;
}
int mid=(l+r)/2;
update(2*node,l,mid,val,p);
update(2*node+1,mid+1,r,val,p);
tree[node][0]=tree[2*node][0]^tree[2*node+1][0];
tree[node][1]=tree[2*node][1]^tree[2*node+1][1];
}
int query(int node,int l,int r,int le, int ri)
{
if(l>ri || r<le) return 0;
if(l>=le && r<=ri) return tree[node][l%2];
int mid=(l+r)/2;
return (query(2*node,l,mid,le,ri)^query(2*node+1,mid+1,r,le,ri));
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,q,x,y,c;
cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>m[i];
build(1,1,n);
for(int i=0;i<q;i++)
{
cin>>c>>x>>y;
if(c==1)
{
update(1,1,n,y,x);
}
if(c==2)
{
cout<<query(1,1,n,x,y)<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
226 ms |
11944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |