This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long tree[4*500000];
vector<int> vec;
void build(int node,int l,int r)
{
if(l==r)
{
tree[node]=vec[l];
}
else
{
int m=(l+r)/2;
build(node*2+1,l,m);
build(node*2+2,m+1,r);
tree[node]=min(tree[node*2+1],tree[node*2+2]);
}
}
void upd(int node,int pos,int x,int l,int r)
{
if(l==r)
{
tree[node]+=x;
return;
}
else
{
int m=(l+r)/2;
if(pos<=m)
{
upd(node*2+1,pos,x,l,m);
}
else
{
upd(node*2+2,pos,x,m+1,r);
}
tree[node]=tree[node*2+1]+tree[node*2+2];
}
}
long long sum(int node,int l, int r,int L,int R)
{
if(l>R || r<L)
{
return 0;
}
else if(l>=L && r<=R)
{
return tree[node];
}
else
{
int m=(l+r)/2;
return sum(node*2+1,l,m,L,R)+sum(node*2+2,m+1,r,L,R);
}
}
int main()
{
int n,q;
cin>>n>>q;
vector<int> vec;
for(;n>0;n--)
{
int x;
cin>>x;
vec.push_back(x);
}
for(;q>0;q--)
{
int x;
cin>>x;
if(x==1)
{
int a,b;
cin>>a>>b;
vec[a-1]=b;
}
else
{
int a,b;
cin>>a>>b;
if((b-a+1)%2==0)
{
cout<<0<<endl;
}
else
{
int res=-1;
int br=0;
for(int i=a-1;i<b;i=i+2)
{
if(res==-1)
res=vec[i];
else
{
res=res^vec[i];
}
}
cout<<res<<endl;
}
}
}
return 0;
}
Compilation message (stderr)
xoranges.cpp: In function 'int main()':
xoranges.cpp:94:21: warning: unused variable 'br' [-Wunused-variable]
94 | int br=0;
| ^~
# | 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... |