#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
int t[2][N];
void upd(int ind, int val){
for(int i = ind + 1; i < N; i += i & -i){
t[ind & 1][i] ^= val;
}
}
int get(int par, int ind){
int res = 0;
for(; ind > 0; ind -= ind & -ind){
res ^= t[par][ind];
}
return res;
}
int get(int par, int l, int r){
return get(par, r) ^ get(par, l);
}
int n, q, a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
for(int i = 0; i < n; ++i){
cin >> a[i];
upd(i, a[i]);
}
while(q--){
int type;
cin >> type;
if(type == 1){
int ind, val;
cin >> ind >> val;
ind--;
upd(ind, a[ind] ^ val);
a[ind] = val;
}
if(type == 2){
int l, r;
cin >> l >> r;
l--;
r--;
int ans = 0;
if((l & 1) & (r & 1)){
ans ^= get(1, l, r + 1);
}
if(((l & 1) ^ 1) & ((r & 1) ^ 1)){
ans ^= get(0, l, r + 1);
}
cout << ans << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
640 KB |
Output is correct |
12 |
Correct |
8 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
688 KB |
Output is correct |
14 |
Correct |
7 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
114 ms |
11128 KB |
Output is correct |
2 |
Correct |
113 ms |
11128 KB |
Output is correct |
3 |
Correct |
116 ms |
11128 KB |
Output is correct |
4 |
Correct |
113 ms |
10744 KB |
Output is correct |
5 |
Correct |
109 ms |
10744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
640 KB |
Output is correct |
12 |
Correct |
8 ms |
640 KB |
Output is correct |
13 |
Correct |
9 ms |
688 KB |
Output is correct |
14 |
Correct |
7 ms |
640 KB |
Output is correct |
15 |
Correct |
114 ms |
11128 KB |
Output is correct |
16 |
Correct |
113 ms |
11128 KB |
Output is correct |
17 |
Correct |
116 ms |
11128 KB |
Output is correct |
18 |
Correct |
113 ms |
10744 KB |
Output is correct |
19 |
Correct |
109 ms |
10744 KB |
Output is correct |
20 |
Correct |
121 ms |
10872 KB |
Output is correct |
21 |
Correct |
123 ms |
10872 KB |
Output is correct |
22 |
Correct |
119 ms |
10872 KB |
Output is correct |
23 |
Correct |
112 ms |
10744 KB |
Output is correct |
24 |
Correct |
114 ms |
10872 KB |
Output is correct |