Submission #1099461

#TimeUsernameProblemLanguageResultExecution timeMemory
1099461vjudge1XORanges (eJOI19_xoranges)C++17
38 / 100
411 ms11092 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n, q; cin >> n >> q; vector<int> a(n + 1); vector<int> odd(n + 1), even(n + 1); for (int i = 1; i <= n; i++){ cin >> a[i]; if (i % 2 == 0){ even[i] ^= even[i - 2] ^ a[i]; }else if (i % 2 == 1){ if (i == 1) odd[i] = a[i]; else odd[i] ^= odd[i - 2] ^ a[i]; } } while(q--){ int t, l, u; cin >> t >> l >> u; int x = 0; if (t == 2){ if ((u - l + 1) % 2 == 0){ cout << 0 << endl; }else{ if (u % 2 == 0){ cout << (even[u] ^ even[l - 2] )<< endl; }else{ if (l == 1) cout << odd[u] << endl; else cout << (odd[u] ^ odd[l - 2]) << endl; } } }else{ a[l] = u; } } }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:24:13: warning: unused variable 'x' [-Wunused-variable]
   24 |         int x = 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...