Submission #446788

#TimeUsernameProblemLanguageResultExecution timeMemory
446788fuad27XORanges (eJOI19_xoranges)C++14
38 / 100
609 ms4632 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int fenwick[100000][2] = {0}, v[200010]; void upd(int i, int w, int r) { while(i <= 100000) { fenwick[i][w] ^= r; i += i&(-i); } } int getXor(int i, int w) { int x = 0; while(i>0) { x^=fenwick[i][w]; i -= i&(-i); } return x; } int32_t main () { int n, q; cin >> n >> q; for(int i = 1;i<=n;i++) { cin >> v[i]; upd(ceil(i/2.0), i%2, v[i]); } for(int i = 1;i<=q;i++) { int k; cin >> k; if(k==1) { int j, val; cin >> j >> val; upd(ceil(j/2.0), j%2, (val ^ v[j])); } else { int l, u; cin >> l >> u; if((u - l + 1)%2 == 0)cout<<0<<endl; else { int a = l%2; l-=2; int ans = getXor(ceil(u/2.0), a) ^ getXor(ceil(l/2.0), a);cout<<ans<<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...