#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=2e5+5;
int t[2][2*N]{0};
int a[N]{0};
int qr(int i,int l,int r,int sz,int res=0){
for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
if(l&1)res^=t[i][l++];
if(r&1)res^=t[i][--r];
}return res;
}
void upd(int i,int id,int amt,int sz){
id+=sz;t[i][id]=amt;
for(id>>=1;id;id>>=1)t[i][id]=t[i][2*id]^t[i][2*id+1];
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,q;cin>>n>>q;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i+=2)t[0][i+n]=a[i];
for(int i=1;i<n;i+=2)t[1][i+n]=a[i];
for(int i=n-1;i>0;i--)t[0][i]=t[0][2*i]^t[0][2*i+1],t[1][i]=t[1][2*i]^t[1][2*i+1];
while(q--){
int o;cin>>o;
if(o==1){
int i,j;cin>>i>>j;
if((i-1)&1)upd(1,i-1,j,n);
else upd(0,i-1,j,n);
}
else {
int l,r;cin>>l>>r;
if((r-l+1)%2==0)cout<<0<<'\n';
else cout<<qr((l-1)%2,l-1,r,n)<<'\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
2 ms |
2788 KB |
Output is correct |
12 |
Correct |
2 ms |
2652 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
5348 KB |
Output is correct |
2 |
Correct |
78 ms |
8088 KB |
Output is correct |
3 |
Correct |
88 ms |
8244 KB |
Output is correct |
4 |
Correct |
73 ms |
8060 KB |
Output is correct |
5 |
Correct |
69 ms |
8060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
2 ms |
2788 KB |
Output is correct |
12 |
Correct |
2 ms |
2652 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
15 |
Correct |
76 ms |
5348 KB |
Output is correct |
16 |
Correct |
78 ms |
8088 KB |
Output is correct |
17 |
Correct |
88 ms |
8244 KB |
Output is correct |
18 |
Correct |
73 ms |
8060 KB |
Output is correct |
19 |
Correct |
69 ms |
8060 KB |
Output is correct |
20 |
Correct |
71 ms |
7760 KB |
Output is correct |
21 |
Correct |
72 ms |
7812 KB |
Output is correct |
22 |
Correct |
70 ms |
7756 KB |
Output is correct |
23 |
Correct |
69 ms |
7912 KB |
Output is correct |
24 |
Correct |
74 ms |
7956 KB |
Output is correct |