Submission #237576

#TimeUsernameProblemLanguageResultExecution timeMemory
237576HalfXORanges (eJOI19_xoranges)C++14
100 / 100
763 ms8056 KiB
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> #include <cmath> using namespace std; typedef vector<int> vi; typedef pair<int,int> pi; typedef long long ll; #define loop(i,a,b) for (int i = a; i <= b; i++) #define INF ((unsigned) ~0) #define F first #define S second #define PB push_back #define MP make_pair const int MXN = 200000; int n, q; int st[2*MXN]; int gi(int i){ if(i % 2 == 0) return i / 2; return (n + i) / 2; } int rxq(int l, int r){ int res = 0; for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l&1) res ^= st[l++]; if (r&1) res ^= st[--r]; } return res; } int main(){ cin >> n >> q; for(int i = 0; i < n; i++) cin >> st[gi(i) + n]; for(int i = n - 1; i > 1; i--) st[i] = st[i<<1] ^ st[i<<1|1]; while(q--){ int tp, a, b; cin >> tp >> a >> b; a--; if(tp == 1){ a = gi(a) + n; st[a] = b; while(a >= 1){ a = a >> 1; st[a] = st[a<<1] ^ st[a<<1|1]; } }else{ b--; if(a % 2 == b % 2){ cout << rxq(gi(a), gi(b) + 1) << "\n"; }else{ cout << "0\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...