제출 #1098073

#제출 시각아이디문제언어결과실행 시간메모리
1098073Alihan_8XORanges (eJOI19_xoranges)C++17
0 / 100
130 ms13408 KiB
#include <bits/stdc++.h> using namespace std; #define ar array const int N = 2e5 + 1; int n; struct SegTree{ vector <ar<int,2>> T; SegTree(){ T.resize(N * 4, {0, 0}); } void upd(int v, int l, int r, int p, int x){ if ( l == r ){ T[v][0] = x; return; } int m = (l + r) / 2; if ( m >= p ) upd(v * 2, l, m, p, x); else upd(v * 2 + 1, m + 1, r, p, x); int b = (m - l + 1) & 1; T[v][0] = T[v * 2][0] ^ T[v * 2 + 1][b]; T[v][1] = T[v * 2][1] ^ T[v * 2 + 1][b ^ 1]; } void upd(int p, int x){ upd(1, 0, n - 1, p, x); } int get(int v, int l, int r, int tl, int tr, int k){ if ( l > tr || r < tl ) return 0; if ( tl <= l && tr >= r ) return T[v][k]; int m = (l + r) / 2; int b = max(0, tl - m + 1) & 1; return get(v * 2, l, m, tl, tr, k) ^ get(v * 2 + 1, m + 1, r, tl, tr, k ^ b); } int qry(int l, int r){ return get(1, 0, n - 1, l, r, 0); } } seg; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int q; cin >> n >> q; for ( int i = 0; i < n; i++ ){ int x; cin >> x; seg.upd(i, x); } while ( q-- ){ int t, l, u; cin >> t >> l >> u; if ( t == 1 ){ seg.upd(l - 1, u); } else cout << seg.qry(l - 1, u - 1) << '\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...