Submission #419989

#TimeUsernameProblemLanguageResultExecution timeMemory
419989farukXORanges (eJOI19_xoranges)C++17
18 / 100
5 ms6732 KiB
#include <iostream> #include <algorithm> #include <vector> #include <stack> #include <string> #include <iomanip> #include <bitset> #include <cstring> #include <queue> #include <math.h> #define ll long long #define pii pair<int, int> using namespace std; int n, q; void update(vector<int> &tree, int index, int value) { int oldValue = tree[index]; for (; index > 0; index /= 2) tree[index] ^= oldValue, tree[index] ^= value; } int query(vector<int>& tree, int l, int r) { int out = 0; r++; for (l += n, r += n; l < r; l /= 2, r /= 2) { if (l & 1) out ^= tree[l++]; if (r & 1) out ^= tree[--r]; } return out; } int niz[(int)1e5]; vector<int> parno; vector<int> neparno; int main() { cin >> n >> q; parno.resize(2 * n + 1); neparno.resize(2 * n + 1); for (int i = n; i < 2 * n; i++) { cin >> niz[i]; if ((i - n) % 2 == 0) update(parno, i, niz[i]); else update(neparno, i, niz[i]); } for (int i = 0; i < q; i++) { int type, r, l; cin >> type >> l >> r; r--, l--; if (type == 1) { r++; if (l % 2 == 0) update(parno, l + n, r); else update(neparno, l, r); } else { if ((r - l + 1) % 2 == 0) cout << 0 << endl; else { if (l % 2 == 0) cout << query(parno, l, r) << endl; else cout << query(neparno, l, r) << endl; } } } }
#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...