This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |