Submission #927086

#TimeUsernameProblemLanguageResultExecution timeMemory
927086NurislamWall (IOI14_wall)C++14
0 / 100
113 ms10320 KiB
//~ #include "wall.h" #include <bits/stdc++.h> //~ #include "grader.cpp" using namespace std; #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vii; const int N = 2e6+5; pii b[N*4]{};pii inv = {0,0}; ll a[N]{}; void push(ll i, ll l, ll r){ if(l == r){ if(b[i].ss == 0)return; if(b[i].ss == 2){ a[l] = min(b[i].ff, a[l]); }else{ a[l] = max(b[i].ff, a[l]); } b[i] = {0,0}; return; } b[i*2] = b[i]; b[i*2+1] = b[i]; b[i] = {0, 0}; } void upd(ll i, ll l, ll r, ll tl, ll tr, pii val){ if(l > tr || r < tl || r < l)return; if(tl <= l && r <= tr){ b[i] = val; push(i, l, r); return; } ll m = (l+r)>>1; upd(i*2, l, m, tl, tr, val); upd(i*2+1, m+1, r, tl, tr, val); } int get(ll i, ll l, ll r, ll ps){ if(b[i] != inv)push(i, l, r); if(l == r && l == ps)return a[ps]; ll m = (l+r)>>1; if(ps <= m)return get(i*2, l, m, ps); else return get(i*2+1, m+1, r, ps); } void buildWall(int n, int k, int op[], int l[], int r[], int h[], int finalHeight[]){ for(int i = 0; i < k; i++){ upd(1, 0, n-1, l[i], r[i], {h[i], op[i]}); //~ for(int i = 0; i < n; i++){ //~ finalHeight[i] = get(1, 0, n-1, i); //~ cout << a[i] << ' '; //~ }cout << '\n'; } for(int i = 0; i < n; i++){ finalHeight[i] = get(1, 0, n-1, i); //~ cout << a[i] << ' '; } //~ cout << '\n'; return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...