Submission #577124

#TimeUsernameProblemLanguageResultExecution timeMemory
577124dozerXORanges (eJOI19_xoranges)C++14
100 / 100
163 ms16148 KiB
#include <bits/stdc++.h> using namespace std; #define sp " " #define endl "\n" #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define pb push_back #define pii pair<int, int> #define st first #define nd second #define N 200005 #define L(node) node * 2 #define R(node) node * 2 + 1 #define int long long int arr[N], tree[2][4 * N]; void update(int node, int l, int r, int sl, int x, int par) { if (l > r || l > sl || r < sl) return; if (l == r) { if (l == sl) tree[par][node] = x; return; } int mid = (l + r) / 2; update(L(node), l, mid, sl, x, par); update(R(node), mid + 1, r, sl, x, par); tree[par][node] = tree[par][L(node)] ^ tree[par][R(node)]; } int find(int node, int l, int r, int sl, int sr, int par) { if (l > r || l > sr || r < sl) return 0; if (l >= sl && r <= sr) return tree[par][node]; int mid = (l + r) / 2; return find(L(node), l, mid, sl, sr, par) ^ find(R(node), mid + 1, r, sl, sr, par); } int32_t main() { //fileio(); fastio(); int n, q; cin>>n>>q; for (int i = 1; i <= n; i++) { cin>>arr[i]; update(1, 1, n, i, arr[i], i % 2); } while(q--) { int type; cin>>type; if (type == 1) { int i, x; cin>>i>>x; arr[i] = x; update(1, 1, n, i, x, i % 2); } else { int l, r; cin>>l>>r; if ((r - l + 1) % 2 == 0) cout<<0<<endl; else cout<<find(1, 1, n, l, r, l % 2)<<endl; } } cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\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...