#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int a1[100001],a2[100001];
int t1[400001];
int t2[400001];
void build1(int v,int tl,int tr){
if(tl==tr)
t1[v]=a1[tl];
else{
int m=(tl+tr)/2;
build1(2*v,tl,m);
build1(2*v+1,m+1,tr);
t1[v]=t1[2*v]^t1[2*v+1];
}
}
int get1(int v,int tl,int tr,int l,int r){
if(l==tl&&r==tr)
return t1[v];
int m=(tl+tr)/2;
if(r<=m)
return get1(2*v,tl,m,l,r);
else{
if(l>m)
return get1(2*v+1,m+1,tr,l,r);
else{
return get1(2*v,tl,m,l,m)^get1(2*v+1,m+1,tr,m+1,r);
}
}
}
void update1(int v,int tl,int tr,int p,int x){
if(tl==tr)
t1[v]=x;
else{
int m=(tl+tr)/2;
if(p<=m)
update1(2*v,tl,m,p,x);
else
update1(2*v+1,m+1,tr,p,x);
t1[v]=t1[2*v]^t1[2*v+1];
}
}
void build2(int v,int tl,int tr){
if(tl==tr)
t2[v]=a2[tl];
else{
int m=(tl+tr)/2;
build2(2*v,tl,m);
build2(2*v+1,m+1,tr);
t2[v]=t2[2*v]^t2[2*v+1];
}
}
int get2(int v,int tl,int tr,int l,int r){
if(l==tl&&r==tr)
return t2[v];
int m=(tl+tr)/2;
if(r<=m)
return get2(2*v,tl,m,l,r);
else{
if(l>m)
return get2(2*v+1,m+1,tr,l,r);
else{
return get2(2*v,tl,m,l,m)^get2(2*v+1,m+1,tr,m+1,r);
}
}
}
void update2(int v,int tl,int tr,int p,int x){
if(tl==tr)
t2[v]=x;
else{
int m=(tl+tr)/2;
if(p<=m)
update2(2*v,tl,m,p,x);
else
update2(2*v+1,m+1,tr,p,x);
t2[v]=t2[2*v]^t2[2*v+1];
}
}
int main(){
int n,t,cnt1=1,cnt2=1;
cin>>n>>t;
for(int k=1;k<=n;k++){
if(k%2==0)
cin>>a1[cnt1],cnt1++;
else
cin>>a2[cnt2],cnt2++;
}
build1(1,1,cnt1-1);
build2(1,1,cnt2-1);
while(t--){
int aa,b,c;
cin>>aa>>b>>c;
if(aa==2){
int len=c-b+1;
if(len%2==0)
cout<<0<<"\n";
else{
int ans;
if(b%2==0){
ans=get1(1,1,cnt1-1,b/2,c/2);
}
else{
ans=get2(1,1,cnt2-1,b/2+1,c/2+1);
}
cout<<ans<<"\n";
}
}
else{
if(b%2==0){
update1(1,1,cnt1-1,b/2,c);
}
else{
update2(1,1,cnt2-1,b/2+1,c);
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
12 ms |
436 KB |
Output is correct |
12 |
Correct |
12 ms |
460 KB |
Output is correct |
13 |
Correct |
15 ms |
516 KB |
Output is correct |
14 |
Correct |
15 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
639 ms |
4272 KB |
Output is correct |
2 |
Correct |
646 ms |
9232 KB |
Output is correct |
3 |
Correct |
641 ms |
9244 KB |
Output is correct |
4 |
Correct |
629 ms |
8772 KB |
Output is correct |
5 |
Correct |
619 ms |
8916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
12 ms |
436 KB |
Output is correct |
12 |
Correct |
12 ms |
460 KB |
Output is correct |
13 |
Correct |
15 ms |
516 KB |
Output is correct |
14 |
Correct |
15 ms |
528 KB |
Output is correct |
15 |
Correct |
639 ms |
4272 KB |
Output is correct |
16 |
Correct |
646 ms |
9232 KB |
Output is correct |
17 |
Correct |
641 ms |
9244 KB |
Output is correct |
18 |
Correct |
629 ms |
8772 KB |
Output is correct |
19 |
Correct |
619 ms |
8916 KB |
Output is correct |
20 |
Correct |
491 ms |
8872 KB |
Output is correct |
21 |
Correct |
483 ms |
8908 KB |
Output is correct |
22 |
Correct |
487 ms |
8940 KB |
Output is correct |
23 |
Correct |
599 ms |
8808 KB |
Output is correct |
24 |
Correct |
603 ms |
8820 KB |
Output is correct |