#include<bits/stdc++.h>
using namespace std;
struct fenwick {
int v[1000000] = {0};
void update(int i, int val) {
i++;
while(i < 1000000) {
v[i] ^= val;
i += i&(-i);
}
}
int getXor(int i) {
int x = 0;
while(i > 0) {
x ^= v[i];
i -= i & (-i);
}
return x;
}
};
int main () {
int n, q;
cin >> n >> q;
vector<int> v(n, 0);
fenwick x;
fenwick xodd;
for(int i = 0;i<n;i++) {
int p;
cin >> p;
v[i] = p;
x.update(i, p);
if(i%2 == 0) {
xodd.update(i, p);
}
}
while(q--) {
int k;
cin >> k;
if(k == 1) {
int i, val;
cin >> i >> val;
x.update(i, val ^ v[i-1]);
if(i%2 == 1) {
xodd.update(i, val ^ v[i-1]);
}
v[i-1] = val;
}
else {
int l, u;
cin >> l >> u;
if((u - l)%2 == 0) {
if(l%2 == 1) {
int ans = xodd.getXor(u) ^ xodd.getXor(l-1);cout<<ans<<endl;
}
else {
int ans = x.getXor(u) ^ xodd.getXor(u) ^ x.getXor(l-1) ^ xodd.getXor(l-1);cout<<ans<<endl;
}
}
else {
cout<<0<<endl;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
8012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
8064 KB |
Output is correct |
2 |
Correct |
6 ms |
8012 KB |
Output is correct |
3 |
Correct |
6 ms |
8012 KB |
Output is correct |
4 |
Correct |
6 ms |
8012 KB |
Output is correct |
5 |
Correct |
7 ms |
8012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
8012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
607 ms |
10072 KB |
Output is correct |
2 |
Correct |
602 ms |
10200 KB |
Output is correct |
3 |
Correct |
629 ms |
10056 KB |
Output is correct |
4 |
Correct |
606 ms |
10040 KB |
Output is correct |
5 |
Correct |
582 ms |
10056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
8012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |