#include <bits/stdc++.h>
#define N 200005
#define int long long
using namespace std;
int t[4*N][2];
int arr[N];
void upd(int v,int tl,int tr,int pos,int val){
if(tl == tr){
t[v][pos%2] = val;
}
else{
int tm = (tl+tr)/2;
if(pos <= tm)
upd(v*2,tl,tm,pos,val);
else upd(v*2+1,tm+1,tr,pos,val);
t[v][0] = t[v*2][0] ^ t[v*2+1][0];
t[v][1] = t[v*2][1] ^ t[v*2+1][1];
}
}
int get(int v,int tl,int tr,int l,int r,int idx){
if(tr < l || r <tl){
return 0;
}
if(l <= tl && tr <= r){
return t[v][idx];
}
int tm = (tl+tr)/2;
return get(v*2,tl,tm,l,r,idx)^get(v*2+1,tm+1,tr,l,r,idx);
}
void solve(){
int n,q;
cin >> n >> q;
for(int i=1;i<=n;i++){
cin >> arr[i];
upd(1,1,n,i,arr[i]);
}
while(q--){
int type;
cin >> type;
if(type == 1){
int pos,val;
cin >> pos >> val;
upd(1,1,n,pos,val);
}
if(type == 2){
int l,r;
cin >> l >> r;
if((r-l)%2){
cout << 0 << "\n";
continue;
}
cout << get(1,1,n,l,r,l%2) << "\n";
}
}
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
296 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 |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
4 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
11888 KB |
Output is correct |
2 |
Correct |
210 ms |
11420 KB |
Output is correct |
3 |
Correct |
206 ms |
11416 KB |
Output is correct |
4 |
Correct |
179 ms |
11428 KB |
Output is correct |
5 |
Correct |
179 ms |
11436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
4 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
217 ms |
11888 KB |
Output is correct |
16 |
Correct |
210 ms |
11420 KB |
Output is correct |
17 |
Correct |
206 ms |
11416 KB |
Output is correct |
18 |
Correct |
179 ms |
11428 KB |
Output is correct |
19 |
Correct |
179 ms |
11436 KB |
Output is correct |
20 |
Correct |
204 ms |
11184 KB |
Output is correct |
21 |
Correct |
202 ms |
11012 KB |
Output is correct |
22 |
Correct |
195 ms |
11000 KB |
Output is correct |
23 |
Correct |
180 ms |
11384 KB |
Output is correct |
24 |
Correct |
180 ms |
11380 KB |
Output is correct |