#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN = 2e5 + 5;
void update(int l,int r, int idx , int val , int node , vector<int>& seg){
if(l>idx || r<idx) return ;
if(l == r){
seg[node] = val;
return ;
}
int mid = (l + r) / 2;
update(l,mid , idx,val , node*2 ,seg);
update(mid+1,r, idx,val , node*2 + 1,seg);
seg[node] = seg[node*2] ^ seg[node*2 + 1];
}
int query(int l,int r, int curr_l , int curr_r , int node ,vector<int>& seg){
if(curr_l>r || curr_r<l) return 0;
if(l<=curr_l && curr_r<=r) return seg[node];
int mid = (curr_l + curr_r) / 2;
return query(l,r,curr_l,mid , node*2 ,seg) ^ query(l,r,mid+1,curr_r,node*2 + 1 , seg);
}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
int n,q;
cin>> n >> q;
vector<int> segA(4*n , 0);
vector<int> segB(4*n , 0);
for(int i=1;i<=n;i++){
int val;
cin>> val;
if(i%2 == 1) update(1,n,i,val,1,segA);
else update(1,n,i,val,1,segB);
}
while(q--){
int cmd;
cin>> cmd;
if(cmd == 1){
int idx,val;
cin>> idx >> val;
if(idx%2 == 1) update(1,n,idx,val,1,segA);
else update(1,n,idx,val,1,segB);
}else{
int l,r;
cin>> l >> r;
int len = r-l+1;
if(len % 2 == 0) cout<< 0 << "\n";
else{
if(l%2 == 1) cout<< query(l,r,1,n,1,segA) << "\n";
else cout<< query(l,r,1,n,1,segB) << "\n";
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
856 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
7776 KB |
Output is correct |
2 |
Correct |
120 ms |
7892 KB |
Output is correct |
3 |
Correct |
120 ms |
7752 KB |
Output is correct |
4 |
Correct |
114 ms |
7760 KB |
Output is correct |
5 |
Correct |
113 ms |
7764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
856 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
624 KB |
Output is correct |
15 |
Correct |
146 ms |
7776 KB |
Output is correct |
16 |
Correct |
120 ms |
7892 KB |
Output is correct |
17 |
Correct |
120 ms |
7752 KB |
Output is correct |
18 |
Correct |
114 ms |
7760 KB |
Output is correct |
19 |
Correct |
113 ms |
7764 KB |
Output is correct |
20 |
Correct |
125 ms |
7248 KB |
Output is correct |
21 |
Correct |
125 ms |
12344 KB |
Output is correct |
22 |
Correct |
131 ms |
12360 KB |
Output is correct |
23 |
Correct |
122 ms |
12372 KB |
Output is correct |
24 |
Correct |
113 ms |
12368 KB |
Output is correct |