Submission #791396

#TimeUsernameProblemLanguageResultExecution timeMemory
791396otariusXORanges (eJOI19_xoranges)C++17
100 / 100
124 ms10444 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; int t[800040][2]; void update(int v, int tl, int tr, int pos, int val) { if (tl == tr) { t[v][pos & 1] = val; return; } int tm = (tl + tr) / 2; if (pos <= tm) update(2 * v, tl, tm, pos, val); else update(2 * v + 1, tm + 1, tr, pos, val); t[v][0] = (t[2 * v][0] ^ t[2 * v + 1][0]); t[v][1] = (t[2 * v][1] ^ t[2 * v + 1][1]); } int getans(int v, int tl, int tr, int l, int r, int idx) { if (l > r) return 0; if (tl == l && tr == r) return t[v][idx]; int tm = (tl + tr) / 2; return (getans(2 * v, tl, tm, l, min(r, tm), idx) ^ getans(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, idx)); } void solve() { int n, q; cin >> n >> q; for (int i = 1, x; i <= n; i++) { cin >> x; update(1, 1, n, i, x); } int tc, l, r; for (int i = 1; i <= q; i++) { cin >> tc >> l >> r; if (tc == 1) update(1, 1, n, l, r); else { if ((r - l + 1) % 2 == 0) cout << "0\n"; else cout << getans(1, 1, n, l, r, l & 1) << '\n'; } } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\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...