Submission #437446

#TimeUsernameProblemLanguageResultExecution timeMemory
437446MinhQNgoXORanges (eJOI19_xoranges)C++17
75 / 100
1081 ms8704 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200005; int a[N]; long long p[N]; int n; void update() { int pos, val; cin >> pos >> val; a[pos] = val; p[1] = a[1]; for (int i = 2; i <= n; i++) p[i] = p[i - 2] ^ a[i]; } void query() { int l, r; cin >> l >> r; if ((r - l + 1) % 2 == 0) cout << 0 << '\n'; else { cout << (p[r] ^ p[l] ^ a[l]) << '\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int q; cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> a[i]; if (i == 1) p[i] = a[i]; else p[i] = p[i - 2] ^ a[i]; } for (int _ = 0; _ < q; _++) { int t; cin >> t; if (t == 1) update(); else query(); } }
#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...