Submission #979456

#TimeUsernameProblemLanguageResultExecution timeMemory
979456LOLOLOXORanges (eJOI19_xoranges)C++17
100 / 100
79 ms10536 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (int)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 3e5 + 10; struct fen{ vector <ll> f; int N; void ass(int n) { N = n + 100; f.assign(N + 1, 0); } void upd(int i, ll x) { for (;i; i -= i & (-i)) f[i] ^= x; } ll get(int i) { ll s = 0; for (; i <= N; i += i & (-i)) s ^= f[i]; return s; } }; int a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; fen f1, f0; f1.ass(n + 1); f0.ass(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; if (i % 2) { f1.upd(i, a[i]); } else { f0.upd(i, a[i]); } } for (int i = 1; i <= q; i++) { int t, x, y; cin >> t >> x >> y; if (t == 1) { if (x % 2) { f1.upd(x, y ^ a[x]); } else { f0.upd(x, y ^ a[x]); } a[x] = y; } if (t == 2) { if ((y - x + 1) % 2 == 0) { cout << 0 << '\n'; continue; } if (x % 2) { cout << (f1.get(x) ^ f1.get(y + 1)) << '\n'; } else { cout << (f0.get(x) ^ f0.get(y + 1)) << '\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...