#include <bits/stdc++.h>
using namespace std;
vector<int> st;
vector<int> st2;
void build(vector<int>& a, int v, int tl, int tr){
if(tl==tr) st[v]=a[tl];
else{
int tm=(tl+tr)/2;
build(a,v*2,tl,tm);
build(a,v*2+1,tm+1,tr);
st[v]=st[v*2]^st[v*2+1];
}
}
int XUM(int v, int tl, int tr, int l, int r){
if(l>r) return 0;
if(l==tl and r==tr) return st[v];
int tm=(tl+tr)/2;
return XUM(v*2,tl,tm,l,min(r,tm))^XUM(v*2+1,tm+1,tr,max(l,tm+1),r);
}
void update(int v, int tl, int tr, int pos, int new_val){
if(tl==tr){
st[v]=new_val;
}
else{
int tm=(tl+tr)/2;
if(pos<=tm) update(v*2,tl,tm,pos,new_val);
else update(v*2+1,tm+1,tr,pos,new_val);
st[v]=st[v*2]^st[v*2+1];
}
}
void build2(vector<int>& a, int v, int tl, int tr){
if(tl==tr) st2[v]=a[tl];
else{
int tm=(tl+tr)/2;
build2(a,v*2,tl,tm);
build2(a,v*2+1,tm+1,tr);
st2[v]=st2[v*2]^st2[v*2+1];
}
}
int XUM2(int v, int tl, int tr, int l, int r){
if(l>r) return 0;
if(l==tl and r==tr) return st2[v];
int tm=(tl+tr)/2;
return XUM2(v*2,tl,tm,l,min(r,tm))^XUM2(v*2+1,tm+1,tr,max(l,tm+1),r);
}
void update2(int v, int tl, int tr, int pos, int new_val){
if(tl==tr){
st2[v]=new_val;
}
else{
int tm=(tl+tr)/2;
if(pos<=tm) update2(v*2,tl,tm,pos,new_val);
else update2(v*2+1,tm+1,tr,pos,new_val);
st2[v]=st2[v*2]^st2[v*2+1];
}
}
int main(){
int n,q;
scanf("%lld%lld",&n,&q);
vector<int> a;
vector<int> a2;
st.resize(4*((n+1)/2));
st2.resize(4*(n/2));
for(int i=0;i<n;i++){
int x;
scanf("%lld",&x);
if((i&1)==0)a.push_back(x);
else a2.push_back(x);
}
build(a,1,0,((n+1)/2)-1);
build2(a2,1,0,n/2-1);
while(q--){
int action;
scanf("%lld",&action);
if(action==1){
int pos,ch;
scanf("%lld%lld",&pos,&ch);
if((pos&1)!=0) update(1,0,(n+1)/2-1,pos/2,ch);
else update2(1,0,n/2-1,pos/2-1,ch);
}
else{
int l,u;
scanf("%lld%lld",&l,&u);
if(((u-l)&1)==1) printf("%d\n",0);
else{
if((l&1)==1){
int xum=XUM(1,0,((n+1)/2)-1,l/2,u/2);
printf("%lld\n",xum);
}
else{
int xum=XUM2(1,0,(n/2)-1,l/2-1,u/2-1);
printf("%lld\n",xum);
}
}
}
}
return 0;
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:67:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
67 | scanf("%lld%lld",&n,&q);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:67:19: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
67 | scanf("%lld%lld",&n,&q);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:74:19: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
74 | scanf("%lld",&x);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:82:19: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
82 | scanf("%lld",&action);
| ~~~^ ~~~~~~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:85:23: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
85 | scanf("%lld%lld",&pos,&ch);
| ~~~^ ~~~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:85:27: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
85 | scanf("%lld%lld",&pos,&ch);
| ~~~^ ~~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:91:23: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
91 | scanf("%lld%lld",&l,&u);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:91:27: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
91 | scanf("%lld%lld",&l,&u);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
xoranges.cpp:96:32: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
96 | printf("%lld\n",xum);
| ~~~^ ~~~
| | |
| | int
| long long int
| %d
xoranges.cpp:100:32: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
100 | printf("%lld\n",xum);
| ~~~^ ~~~
| | |
| | int
| long long int
| %d
xoranges.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | scanf("%lld%lld",&n,&q);
| ~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
74 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
xoranges.cpp:82:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | scanf("%lld",&action);
| ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:85:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
85 | scanf("%lld%lld",&pos,&ch);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:91:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
91 | scanf("%lld%lld",&l,&u);
| ~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
6760 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |