# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1255069 | mingga | XORanges (eJOI19_xoranges) | C++20 | 53 ms | 3912 KiB |
// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 2e5 + 7;
int n, q, a[N];
struct BIT {
int n;
vector<int> bit;
BIT() {}
BIT(int n) : n(n) {
bit.resize(n + 1, 0);
}
void update(int u, int x) {
for(; u <= n; u += (u & -u)) {
bit[u] ^= x;
}
}
int get(int u) {
int ans = 0;
for(; u > 0; u -= (u & -u)) {
ans ^= bit[u];
}
return ans;
}
int get(int l, int r) {
return get(r) ^ get(l - 1);
}
} bit[2];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
bit[0] = bit[1] = BIT(n);
for(int i = 1; i <= n; i++) {
bit[i & 1].update(i, a[i]);
}
for(int i = 1; i <= q; i++) {
int t, u, v; cin >> t >> u >> v;
if(t == 1) {
bit[u & 1].update(u, v ^ a[u]);
a[u] = v;
} else {
if((v - u + 1) & 1) {
int id = u & 1;
cout << bit[id].get(u, v);
} else cout << 0;
cout << ln;
}
}
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |