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;
#define loop(i,n) for (ll i = 0; i < n; i++)
#define ll long long
#define INF 1e9+5
#define MAXN 200007
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
ll arr[MAXN];
ll seg[4*MAXN][2];
void recalculate(ll int node){
seg[node][0]=seg[2*node+1][0]^seg[2*node+2][0];
seg[node][1]=seg[2*node+1][1]^seg[2*node+2][1];
}
void build(ll node, ll left, ll right){
if(left==right){
if(left%2==0){seg[node][0]=arr[left]; seg[node][1]=0; }
else{ seg[node][1]=arr[left]; seg[node][0]=0;}
}else{
ll middle=(left+right)/2;
build(2*node+1,left,middle);
build(2*node+2,middle+1,right);
recalculate(node);
}
}
void update(ll node, ll left, ll right, ll x, ll y){
if(left==right){
if(left%2==0){seg[node][0]=y; seg[node][1]=0; }
else{ seg[node][1]=y; seg[node][0]=0;}
}else{
ll middle=(left+right)/2;
if(x<=middle){
update(2*node+1,left,middle,x,y);
}else{
update(2*node+2,middle+1,right,x,y);
}
recalculate(node);
}
}
ll bruh;
ll querie(ll node, ll left, ll right, ll a, ll b){
if(a<=left&&b>=right)return seg[node][bruh];
ll middle=(left+right)/2,ans=0;
if(a<=middle)ans^=querie(2*node+1,left,middle,a,b);
if(b>=middle+1)ans^=querie(2*node+2,middle+1,right,a,b);
return ans;
}
int main(){
ll n,q,type,i,j,l,r;
cin>>n>>q;
loop(i,n){
scanf("%lld",&arr[i+1]);
}
build(0,1,n);
while(q--){
scanf("%lld",&type);
if(type==1){
scanf("%lld%lld",&i,&j);
arr[i]=j;
update(0,1,n,i,j);
}else{
scanf("%lld%lld",&l,&r);
if((r-l)%2==1){
printf("0\n");
}else{
bruh=l%2;
printf("%lld\n",querie(0,1,n,l,r));
}
}
}
return 0;
}
Compilation message (stderr)
xoranges.cpp: In function 'int main()':
xoranges.cpp:87:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&arr[i+1]);
~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:94:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&type);
~~~~~^~~~~~~~~~~~~~
xoranges.cpp:98:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&i,&j);
~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:105:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&l,&r);
~~~~~^~~~~~~~~~~~~~~~~~
# | 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... |