Submission #1137251

#TimeUsernameProblemLanguageResultExecution timeMemory
1137251aykhnXORanges (eJOI19_xoranges)C++20
100 / 100
72 ms11336 KiB
#include <bits/stdc++.h> // author: aykhn using namespace std; typedef long long ll; #define TC int t; cin >> t; while (t--) _(); #define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(v) v.begin(), v.end() #define pii pair<int, int> #define mpr make_pair #define eb emplace_back #define pdd pair<double, double> #define pb push_back #define ts to_string #define fi first #define se second #define int ll #define ins insert #define inf 0x3F3F3F3F #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; const int MXN = 2e5 + 5; int n, q; int a[MXN]; struct SegTree { int sz; vector<int> st; void build(int l, int r, int x, int id) { if (l + 1 == r) { if (l < n && (l & 1) == id) st[x] = a[l]; return; } int mid = (l + r) >> 1; build(l, mid, 2*x + 1, id); build(mid, r, 2*x + 2, id); st[x] = (st[2*x + 1] ^ st[2*x + 2]); } void build(int id) { sz = 1; while (sz < n) sz <<= 1; st.assign(sz << 1, 0); build(0, sz, 0, id); } void make(int ind, int val, int l, int r, int x) { if (l + 1 == r) { st[x] = val; return; } int mid = (l + r) >> 1; if (ind < mid) make(ind, val, l, mid, 2*x + 1); else make(ind, val, mid, r, 2*x + 2); st[x] = (st[2*x + 1] ^ st[2*x + 2]); } void make(int ind, int val) { make(ind, val, 0, sz, 0); } int get(int lx, int rx, int l, int r, int x) { if (l >= rx || r <= lx) return 0; if (l >= lx && r <= rx) return st[x]; int mid = (l + r) >> 1; return (get(lx, rx, l, mid, 2*x + 1) ^ get(lx, rx, mid, r, 2*x + 2)); } int get(int lx, int rx) { return get(lx, rx + 1, 0, sz, 0); } }; SegTree st[2]; signed main() { OPT; cin >> n >> q; for (int i = 0; i < n; i++) cin >> a[i]; st[0].build(0); st[1].build(1); while (q--) { int type; cin >> type; if (type == 1) { int ind, val; cin >> ind >> val; ind--; st[ind & 1].make(ind, val); a[ind] = val; } else { int l, r; cin >> l >> r; l--; r--; if (!((r - l + 1) & 1)) { cout << "0\n"; continue; } cout << st[l & 1].get(l, r) << '\n'; } } }
#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...