Submission #999723

#TimeUsernameProblemLanguageResultExecution timeMemory
999723vjudge1XORanges (eJOI19_xoranges)C++17
0 / 100
18 ms10032 KiB
#include <bits/stdc++.h> // author : Pluton #define OPT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int ll #define ll long long #define pb push_back #define arr array #define fi first #define se second #define rep(i,j,k) for(int i = j; i <= k; ++i) #define all(a) a.begin(),a.end() #define pii pair<int,int> using namespace std; const int INF = 1e18; struct BIT { int n; vector<int> ft; void init(int N) { n = N + 5; ft.assign(n + 5, 0); } void add(int pos, int val) { for (pos = pos + 1; pos <= n; pos += pos & -pos) ft[pos] += val; } int get(int pos, int res = 0) { for (pos = pos + 1; pos > 0; pos -= pos & -pos) res += ft[pos]; return res; } }; const int N = 2e5 + 5; vector<int>a(N); vector<array<int,2>>t(N); void build(int node,int l,int r) { if(l == r) { if(l % 2) { t[node][1] = a[l]; t[node][0] = 0; } else { t[node][1] = 0; t[node][0] = a[l]; } return; } int mid = (l + r) >> 1; build(node * 2, l, mid); build(node * 2 + 1, mid + 1, r); t[node][1] = (t[node * 2][1] ^ t[node * 2 + 1][1]); t[node][2] = (t[node * 2][0] ^ t[node * 2 + 1][0]); } void update(int node,int l,int r,int pos,int val) { if(l == r) { if(l % 2) { t[node][1] = val; t[node][0] = 0; } else { t[node][1] = 0; t[node][0] = val; } return; } int mid = (l + r) >> 1; if(pos <= mid) update(node * 2, l, mid, pos, val); else update(node * 2 + 1, mid + 1, r, pos, val); t[node][1] = (t[node * 2][1] ^ t[node * 2 + 1][1]); t[node][0] = (t[node * 2][0] ^ t[node * 2 + 1][0]); } int get_ans(int node,int l,int r, int tl,int tr, int tp) { if(l <= tl && tr <= r) { return t[node][tp]; } if(tr < l || tl > r) { return 0; } int mid = (tl + tr) >> 1; return (get_ans(node * 2, l, r, tl, mid, tp) ^ get_ans(node * 2 + 1, l, r, mid + 1, tr, tp)); } void _() { int n, q; cin >> n >> q; for(int i = 1; i <= n; ++i) cin >> a[i]; build(1,1,n); while(q--) { int t, a, b; cin >> t >> a >> b; if(t == 1) { update(1,1,n,a,b); } else { if((b - a + 1) & 1) { cout << get_ans(1,a,b,1,n,a % 2) << endl; } else { cout << 0 << endl; } } } } signed main() { OPT int tc = 1; while(tc--) { _(); } }
#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...