Submission #446726

#TimeUsernameProblemLanguageResultExecution timeMemory
446726fuad27XORanges (eJOI19_xoranges)C++14
75 / 100
1089 ms3972 KiB
#include<bits/stdc++.h> using namespace std; #define pass true int main () { int n, q; cin >> n >> q; vector<int> prefix(n+1, 0); vector<int> prefixOdd(n+1, 0); vector<int> v(n, 0); bool check = false; for(int i = 0;i<n;i++) { int p; cin >> p; prefix[i+1] = prefix[i] ^ p; if(i%2 == 0) { prefixOdd[i+1] = prefixOdd[i] ^ p; } else { prefixOdd[i+1] = prefixOdd[i]; } v[i] = p; } while(q--) { int k; cin >> k; if(k == 1) { check = true; int i, j; cin >> i >> j; v[i-1] = j; } else { int l, u; cin >> l >> u; if(!check) { if((u - l)%2 == 0) { if(l%2 == 1) { int ans = prefixOdd[u] ^ prefixOdd[l-1]; cout<<(ans)<<endl; } else { int ans = prefix[u] ^ prefixOdd[u] ^ prefix[l-1] ^ prefixOdd[l-1]; cout<<ans<<endl; } } else { cout<<0<<endl; } } else { int s = 0; l--; u = min(u, n); for(int i = l;i<u;i++) { if(((i - l + 1)*(u - i))%2)s^=v[i]; } cout<<s<<endl; } } } }
#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...