Submission #1194445

#TimeUsernameProblemLanguageResultExecution timeMemory
1194445AzeTurk810XORanges (eJOI19_xoranges)C++20
55 / 100
1093 ms14516 KiB
// Telebe of adicto yani AzeTurk810 // // WHY ARE YOU STARING MY CODE Stranger ??!! // //GO AWAY AND DON T look my CODE if i don t know you or you are stalker !!!!(hrrr) // // here about me: I am alone of course, fun , ' , ' , love pyhcics , young(child) , love music , had birds , not a gamer , chess :) , dead to football , you are looking to code , ... ; // // why at 1 japon army march they say "the enemy geniral is a hero , an equal to no one. Both in glory and in victory // the men that follow him are also brave , fearless wariors ..."? #include <bits/stdc++.h> using namespace std; using ll = long long; # define int ll # define ln '\n' # define INFi 1e9 # define INFll 1e18 ll sum(ll a , ll b) { return ((a + b) * (b - a + 1))/2; } struct segmentTree { int N , Null_val; vector<array<int,2>> t; segmentTree(int _n) { t.resize(_n * 4); N = _n; } void build(int v , int l , int r , vector<int> &a) { if(l == r) { t[v][l&1] = a[l]; return; } int mid = (l + r) >> 1; build((v << 1) , l , mid , a); build((v << 1)|1 , mid + 1 , r , a); t[v][0] = (t[(v << 1)][0] ^ t[(v << 1)|1][0]); t[v][1] = (t[(v << 1)][1] ^ t[(v << 1)|1][1]); } void upd(int v , int l , int r , int &val , int &pos) { if(l == r) { t[v][l & 1] = val; return; } int mid = (l + r) >> 1; if(mid >= pos) upd((v << 1) , l , mid , val, pos); else upd((v << 1)|1 , mid + 1 , r , val , pos); t[v][0] = (t[(v << 1)][0] ^ t[(v << 1)|1][0]); t[v][1] = (t[(v << 1)][1] ^ t[(v << 1)|1][1]); } array<int , 2 > ask(int v , int l , int r , int ql , int qr ,int id) { if(ql > r || l > qr) return {0 , 0}; if(ql <= l && r <= qr) return t[v]; int mid = (l + r) >> 1; array<int,2> res = {(ask((v << 1) , l , mid , ql , qr , id)[0] ^ask((v << 1)|1 , mid + 1 , r , ql , qr , id)[0]) ,ask((v << 1) , l , mid , ql , qr , id)[1] ^ ask((v << 1)|1 , mid + 1 , r , ql , qr , id)[1]}; return res; } }; void solve() { int n , q; cin >> n >> q; vector<int> a(n); for(int &i : a) cin >> i; segmentTree t(n); t.build(1 , 0 , n - 1 , a); while(q--) { int tt; cin >> tt; if(tt == 1) { int pos , val; cin >> pos >> val; pos--; t.upd(1 , 0 , n - 1 , val , pos); } else { int l , r; cin >> l >> r; l--;r--; if((r - l + 1)& 1) { cout << t.ask(1 , 0 , n - 1 , l , r , l & 1)[l&1] << ln; } else { cout << 0 << ln; } } } } signed main() { int t = 1; while(t--)solve(); } /* */
#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...