#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[200005],s[2][800020];
void build(int node,int l,int r,int t){
if(l==r){
s[t][node]=arr[(t==0?l*2-1:l*2)];
return;
}
int mid=(l+r)/2;
build(node*2,l,mid,t);
build(node*2+1,mid+1,r,t);
s[t][node]=(s[t][node*2]^s[t][node*2+1]);
return;
}
void update(int node,int l,int r,int x,int y,int t){
if(l>x || r<x)return;
if(l==r){
s[t][node]=y;
return;
}
int mid=(l+r)/2;
update(node*2,l,mid,x,y,t);
update(node*2+1,mid+1,r,x,y,t);
s[t][node]=(s[t][node*2]^s[t][node*2+1]);
return;
}
int query(int node,int l,int r,int x,int y,int t){
if(l>y || r<x)return 0;
if(l>=x && r<=y)return s[t][node];
int mid=(l+r)/2;
return (query(node*2,l,mid,x,y,t)^query(node*2+1,mid+1,r,x,y,t));
}
int32_t main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)cin>>arr[i];
int o=(n+1)/2,e=n/2;
build(1,1,o,0);
build(1,1,e,1);
while(q--){
int a,b,c;
cin>>a>>b>>c;
if(a==1){
if(b%2){
update(1,1,o,(b+1)/2,c,0);
}
else{
update(1,1,e,b/2,c,1);
}
}
else{
if((c-b)%2){
cout<<"0"<<endl;
}
else{
if(b%2){
cout<<query(1,1,o,(b+1)/2,(c+1)/2,0)<<endl;
}
else{
cout<<query(1,1,e,b/2,c/2,1)<<endl;
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
280 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
280 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
8 ms |
572 KB |
Output is correct |
12 |
Correct |
8 ms |
596 KB |
Output is correct |
13 |
Correct |
10 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
420 ms |
7136 KB |
Output is correct |
2 |
Correct |
424 ms |
11996 KB |
Output is correct |
3 |
Correct |
403 ms |
11956 KB |
Output is correct |
4 |
Correct |
384 ms |
11652 KB |
Output is correct |
5 |
Correct |
411 ms |
11552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
280 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
8 ms |
572 KB |
Output is correct |
12 |
Correct |
8 ms |
596 KB |
Output is correct |
13 |
Correct |
10 ms |
596 KB |
Output is correct |
14 |
Correct |
9 ms |
596 KB |
Output is correct |
15 |
Correct |
420 ms |
7136 KB |
Output is correct |
16 |
Correct |
424 ms |
11996 KB |
Output is correct |
17 |
Correct |
403 ms |
11956 KB |
Output is correct |
18 |
Correct |
384 ms |
11652 KB |
Output is correct |
19 |
Correct |
411 ms |
11552 KB |
Output is correct |
20 |
Correct |
320 ms |
11636 KB |
Output is correct |
21 |
Correct |
331 ms |
11732 KB |
Output is correct |
22 |
Correct |
314 ms |
11736 KB |
Output is correct |
23 |
Correct |
393 ms |
11616 KB |
Output is correct |
24 |
Correct |
385 ms |
11668 KB |
Output is correct |