이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |