Submission #1098083

#TimeUsernameProblemLanguageResultExecution timeMemory
1098083Alihan_8XORanges (eJOI19_xoranges)C++17
100 / 100
71 ms8772 KiB
#include <bits/stdc++.h> using namespace std; struct fenwick{ vector <int> fenw; int n; fenwick(int n) : fenw(n + 1, 0), n(n) {} void upd(int i, int v){ for (; i <= n; i += i & -i ) fenw[i] ^= v; } int get(int i){ int cnt = 0; for (; i > 0; i -= i & -i ) cnt ^= fenw[i]; return cnt; } int qry(int l, int r){ if ( (r - l) & 1 ) return 0; return get(r) ^ get(l - 1); } }; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector <int> a(n + 1); vector <fenwick> fn(2, fenwick(n + 1)); for ( int i = 1; i <= n; i++ ){ int x; cin >> x; a[i] = x; fn[i & 1].upd(i, x); } while ( q-- ){ int t, l, u; cin >> t >> l >> u; if ( t == 1 ){ fn[l & 1].upd(l, u); fn[l & 1].upd(l, a[l]); a[l] = u; } else cout << fn[l & 1].qry(l, u) << '\n'; } cout << '\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...