#include <bits/stdc++.h>
using namespace std;
#define N_MAX 200001
int v[N_MAX / 2 + 1][2], aib[N_MAX / 2 + 1][2];
void update(int pos, int newval, int p, int n) {
int oldval = v[pos][p];
v[pos][p] = newval;
while(pos <= n) {
aib[pos][p] ^= oldval;
aib[pos][p] ^= newval;
pos += (pos & (-pos));
}
}
int query(int pos, int p, int n) {
int res = 0;
while(pos > 0) {
res ^= aib[pos][p];
pos -= (pos & (-pos));
}
return res;
}
int main()
{
int q, i, t, a, b, val, n;
cin >> n >> q;
for(i = 1; i <= n; ++i) {
cin >> val;
if(i % 2 == 0) {
update(i / 2, val, 1, n / 2);
}else{
update(i / 2 + 1, val, 0, n / 2 + n % 2);
}
}
while(q--) {
cin >> t >> a >> b;
if(t == 1) {
if(a % 2 == 0) {
update(a / 2, b, 1, n / 2);
}else{
update(a / 2 + 1, b, 0, n / 2 + n % 2);
}
}else{
if(a % 2 == 0) {
if(b % 2 == 1) {
--b;
}
cout << (query(b / 2, 1, n / 2) ^ query((a - 1) / 2, 1, n / 2)) << '\n';
}else{
if(b % 2 == 0) {
--b;
}
cout << (query(b / 2 + 1, 0, n / 2 + n % 2) ^ query((a - 1) / 2, 0, n / 2 + n % 2)) << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
374 ms |
8752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |