제출 #964695

#제출 시각아이디문제언어결과실행 시간메모리
964695PringXORanges (eJOI19_xoranges)C++17
100 / 100
85 ms6500 KiB
#include <bits/stdc++.h> using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) using ll = long long; typedef pair<int, int> pii; const int MXN = 200005; int n, q, a[MXN]; struct BIT { int n, val[MXN]; void init(int _n) { n = _n; fill(val + 1, val + n + 1, 0); } void modify(int id, int v) { for (; id <= n; id += (id & -id)) val[id] ^= v; } int query(int id) { int ans = 0; for (; id > 0; id -= (id & -id)) ans ^= val[id]; return ans; } int query(int l, int r) { return query(r) ^ query(l - 1); } } B0, B1; void miku() { cin >> n >> q; FOR(i, 1, n + 1) cin >> a[i]; B0.init(n / 2 + 1); B1.init(n / 2 + 1); FOR(i, 1, n + 1) { if (i & 1) B1.modify(i / 2 + 1, a[i]); else B0.modify(i / 2, a[i]); } while (q--) { int t, x, y; cin >> t >> x >> y; if (t == 1) { if (x & 1) B1.modify(x / 2 + 1, y ^ a[x]); else B0.modify(x / 2, y ^ a[x]); a[x] = y; } else { if ((y - x) & 1) { cout << 0 << '\n'; } else { if (y & 1) cout << B1.query(x / 2 + 1, y / 2 + 1) << '\n'; else cout << B0.query(x / 2, y / 2) << '\n'; } } } } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); 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...