#include <bits/stdc++.h>
#include <unistd.h>
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define pri(i, poc, n, pov) for(int i = (int) poc; i < (int) n; i += (int) pov)
#define od(i, poc, n, pov) for(int i = (int) poc; i > (int) n; i -= (int) pov)
using namespace std;
const int LOG = 18;
const int OFF = (1 << LOG);
struct node{
int xr[2] = {0, 0};
} tour[OFF * 2];
int n, q;
void update(int x, int val){
x += OFF;
tour[x].xr[x % 2] = val;
x >>= 1;
while(x){
pri(i, 0, 2, 1)
tour[x].xr[i] = tour[x * 2].xr[i] ^ tour[x * 2 + 1].xr[i];
x >>= 1;
}
}
int query(int b, int l, int r, int lo = 0, int hi = OFF, int x = 1){
if(r <= lo || hi <= l) return 0;
if(l <= lo && hi <= r) return tour[x].xr[b];
int mi = (lo + hi) / 2;
return query(b, l, r, lo, mi, x * 2) ^ query(b, l, r, mi, hi, x * 2 + 1);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
pri(i, 0, n, 1){
int x;
cin >> x;
update(i, x);
}
pri(i, 0, q, 1){
int t, x, y;
cin >> t >> x >> y;
if(t == 1){
update(x - 1, y);
} else {
x--;
y--;
int p = (y - x + 1) % 2;
if(!p)
cout << 0 << "\n";
else
cout << query(x % 2, x, y + 1) << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 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 |
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 |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
468 KB |
Output is correct |
12 |
Correct |
3 ms |
464 KB |
Output is correct |
13 |
Correct |
3 ms |
468 KB |
Output is correct |
14 |
Correct |
4 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
128 ms |
6068 KB |
Output is correct |
2 |
Correct |
145 ms |
9584 KB |
Output is correct |
3 |
Correct |
137 ms |
9508 KB |
Output is correct |
4 |
Correct |
118 ms |
9128 KB |
Output is correct |
5 |
Correct |
118 ms |
9076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
468 KB |
Output is correct |
12 |
Correct |
3 ms |
464 KB |
Output is correct |
13 |
Correct |
3 ms |
468 KB |
Output is correct |
14 |
Correct |
4 ms |
464 KB |
Output is correct |
15 |
Correct |
128 ms |
6068 KB |
Output is correct |
16 |
Correct |
145 ms |
9584 KB |
Output is correct |
17 |
Correct |
137 ms |
9508 KB |
Output is correct |
18 |
Correct |
118 ms |
9128 KB |
Output is correct |
19 |
Correct |
118 ms |
9076 KB |
Output is correct |
20 |
Correct |
114 ms |
9236 KB |
Output is correct |
21 |
Correct |
111 ms |
9176 KB |
Output is correct |
22 |
Correct |
134 ms |
9224 KB |
Output is correct |
23 |
Correct |
117 ms |
9084 KB |
Output is correct |
24 |
Correct |
112 ms |
9076 KB |
Output is correct |