#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1LL<<((long long)(bi)))
struct SegTree{
vector<int> segtree;
SegTree(int n){
segtree.resize(tol(ceil(log2(n)+1))-1,0ll);
}
void update(int node, int val){
node+=segtree.size()/2;
segtree[node]=val;
while (node){
node=(node-1)/2;
segtree[node]=segtree[node*2+1]^segtree[node*2+2];
}
}
int query(int tarl, int tarr, int l = 0, int r = -1, int node = 0){
if (r==-1)r = segtree.size()/2;
if (l>=tarl && r<=tarr) return segtree[node];
if (l>tarr || r<tarl) return 0ll;
int mid = l+(r-l)/2;
int lnode = query(tarl, tarr, l, mid, node*2+1);
int rnode = query(tarl, tarr, mid+1, r, node*2+2);
return lnode^rnode;
}
};
int main(){
int n,q;
cin>>n>>q;
vector<SegTree> segtree(2,n);
for (int i = 0; i < n; ++i)
{
int x;cin>>x;
segtree[(i+1)%2].update(i,x);
}
while (q--){
int ty,x,y;
cin>>ty>>x>>y;
if (ty==1){
segtree[x%2].update(x-1,y);
}
else {
if ((y-x)%2){
cout<<0<<endl;
continue;
}
else {
cout<<segtree[x%2].query(x-1,y-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 |
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 |
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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
8 ms |
596 KB |
Output is correct |
12 |
Correct |
7 ms |
568 KB |
Output is correct |
13 |
Correct |
10 ms |
596 KB |
Output is correct |
14 |
Correct |
11 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
490 ms |
10388 KB |
Output is correct |
2 |
Correct |
436 ms |
10336 KB |
Output is correct |
3 |
Correct |
461 ms |
10552 KB |
Output is correct |
4 |
Correct |
421 ms |
10048 KB |
Output is correct |
5 |
Correct |
416 ms |
10068 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
8 ms |
596 KB |
Output is correct |
12 |
Correct |
7 ms |
568 KB |
Output is correct |
13 |
Correct |
10 ms |
596 KB |
Output is correct |
14 |
Correct |
11 ms |
596 KB |
Output is correct |
15 |
Correct |
490 ms |
10388 KB |
Output is correct |
16 |
Correct |
436 ms |
10336 KB |
Output is correct |
17 |
Correct |
461 ms |
10552 KB |
Output is correct |
18 |
Correct |
421 ms |
10048 KB |
Output is correct |
19 |
Correct |
416 ms |
10068 KB |
Output is correct |
20 |
Correct |
342 ms |
10188 KB |
Output is correct |
21 |
Correct |
319 ms |
10104 KB |
Output is correct |
22 |
Correct |
372 ms |
10116 KB |
Output is correct |
23 |
Correct |
465 ms |
10084 KB |
Output is correct |
24 |
Correct |
393 ms |
10056 KB |
Output is correct |