Submission #935085

#TimeUsernameProblemLanguageResultExecution timeMemory
935085ind1vXORanges (eJOI19_xoranges)C++11
100 / 100
105 ms8788 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; struct fenwick_tree { int f[N]; fenwick_tree() { memset(f, 0, sizeof(f)); } void upd(int i, int x) { for (; i < N; i += i & -i) { f[i] ^= x; } } int get(int i) { int res = 0; for (; i > 0; i -= i & -i) { res ^= f[i]; } return res; } int get(int l, int r) { return get(r) ^ get(l - 1); } }; int n, q; int a[N]; fenwick_tree ft[2]; void upd(int i, int j) { ft[i & 1].upd(i, a[i]); a[i] = j; ft[i & 1].upd(i, a[i]); } int get(int l, int u) { if ((l & 1) != (u & 1)) { return 0; } return ft[l & 1].get(l, u); } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> a[i]; ft[i & 1].upd(i, a[i]); } while (q--) { int t; cin >> t; if (t == 1) { int i, j; cin >> i >> j; upd(i, j); } else if (t == 2) { int l, u; cin >> l >> u; cout << get(l, u) << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...