이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n';
const int M = 2e6+5, MOD = 1e9;
int fia[M], fib[M], v[M];
void zor(int pos, int val) {
for (int i = pos; i < M; i += -i&i) fia[i] ^= val;
}
int zum(int pos) {
int ans = 0;
for (int i = pos; i > 0; i -= -i&i) ans ^= fia[i];
return ans;
}
void zur(int pos, int val) {
for (int i = pos; i < M; i += -i&i) fib[i] ^= val;
}
int xum(int pos) {
int ans = 0;
for (int i = pos; i > 0; i -= -i&i) ans ^= fib[i];
return ans;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, t;
cin >> n >> t;
for (int i = 1; i <= n; i++) {
cin >> v[i];
if (i%2) zor(i, v[i]);
else zur(i, v[i]);
}
while (t--) {
int x;
cin >> x;
if (x == 1) {
int a, b;
cin >> a >> b;
if (a%2) zor(a, (b^v[a]));
else zur(a, (b^v[a]));
v[a] = b;
} else {
int l, r;
cin >> l >> r;
if ((r-l)%2) {cout << 0 << endl;}
else if (l%2) {cout << (zum(r)^zum(l-1)) << endl;}
else cout << (xum(r)^xum(l-1)) << endl;
}
}
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... |