이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
int t[2][N];
void upd(int ind, int val){
for(int i = ind + 1; i < N; i += i & -i){
t[ind & 1][i] ^= val;
}
}
int get(int par, int ind){
int res = 0;
for(; ind > 0; ind -= ind & -ind){
res ^= t[par][ind];
}
return res;
}
int get(int par, int l, int r){
return get(par, r) ^ get(par, l);
}
int n, q, a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
for(int i = 0; i < n; ++i){
cin >> a[i];
upd(i, a[i]);
}
while(q--){
int type;
cin >> type;
if(type == 1){
int ind, val;
cin >> ind >> val;
ind--;
upd(ind, a[ind] ^ val);
a[ind] = val;
}
if(type == 2){
int l, r;
cin >> l >> r;
l--;
r--;
int ans = 0;
if((l & 1) & (r & 1)){
ans ^= get(1, l, r + 1);
}
if(((l & 1) ^ 1) & ((r & 1) ^ 1)){
ans ^= get(0, l, r + 1);
}
cout << ans << '\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... |