#include <bits/stdc++.h>
using namespace std;
constexpr int base = 262144;
int tree_par[base*2+9];
int tree_nie[base*2+9];
void add_par(int x, int val){
x += base-1;
tree_par[x] = val;
x = x/2;
while(x>0){
tree_par[x] = tree_par[2*x] ^ tree_par[2*x+1];
x = x/2;
}
}
void add_nie(int x, int val){
x += base-1;
tree_nie[x] = val;
x = x/2;
while(x>0){
tree_nie[x] = tree_nie[2*x] ^ tree_nie[2*x+1];
x = x/2;
}
}
int query_par(int a, int b, int p, int k, int x){
if (p<=a && b<=k){
return tree_par[x];
}
if (a>k || b<p){
return 0;
}
int mid = (a+b)/2;
return query_par(a,mid,p,k,2*x) ^ query_par(mid+1,b,p,k,2*x+1);
}
int query_nie(int a, int b, int p, int k, int x){
if (p<=a && b<=k){
return tree_nie[x];
}
if (a>k || b<p){
return 0;
}
int mid = (a+b)/2;
return query_nie(a,mid,p,k,2*x) ^ query_nie(mid+1,b,p,k,2*x+1);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k,t,a,b;
cin >> n >> k;
for (int x=1;x<=n;x++){
cin >> a;
if (x%2==1){
add_nie(x,a);
}
else{
add_par(x,a);
}
}
while(k--){
cin >> t >> a >> b;
if(t==1){
if (a%2==1){
add_nie(a,b);
}
else{
add_par(a,b);
}
}
else{
if ((b-a+1)%2==0){
cout << "0\n";
}
else{
if(a%2==1){
cout << query_nie(1,base,a,b,1) << "\n";
}
else{
cout << query_par(1,base,a,b,1) << "\n";
}
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
9460 KB |
Output is correct |
2 |
Correct |
100 ms |
9476 KB |
Output is correct |
3 |
Correct |
102 ms |
9460 KB |
Output is correct |
4 |
Correct |
100 ms |
9192 KB |
Output is correct |
5 |
Correct |
94 ms |
9172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
584 KB |
Output is correct |
15 |
Correct |
101 ms |
9460 KB |
Output is correct |
16 |
Correct |
100 ms |
9476 KB |
Output is correct |
17 |
Correct |
102 ms |
9460 KB |
Output is correct |
18 |
Correct |
100 ms |
9192 KB |
Output is correct |
19 |
Correct |
94 ms |
9172 KB |
Output is correct |
20 |
Correct |
87 ms |
9160 KB |
Output is correct |
21 |
Correct |
90 ms |
9236 KB |
Output is correct |
22 |
Correct |
94 ms |
9280 KB |
Output is correct |
23 |
Correct |
92 ms |
9164 KB |
Output is correct |
24 |
Correct |
97 ms |
9132 KB |
Output is correct |