Submission #385431

#TimeUsernameProblemLanguageResultExecution timeMemory
385431KeshiWall (IOI14_wall)C++17
100 / 100
793 ms97388 KiB
//In the name of God #include <bits/stdc++.h> #include "wall.h" using namespace std; typedef int ll; typedef pair<ll, ll> pll; const ll maxn = 2e6 + 100; const ll mod = 1e9 + 7; const ll inf = 1e9; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() #define lc (id << 1) #define rc (lc | 1) pll seg[maxn << 2]; ll ans[maxn]; pll Do(pll f, pll s){ if(f.S < s.F) return Mp(s.F, s.F); if(f.F > s.S) return Mp(s.S, s.S); return Mp(max(f.F, s.F), min(f.S, s.S)); } void shift(ll id){ seg[lc] = Do(seg[lc], seg[id]); seg[rc] = Do(seg[rc], seg[id]); seg[id] = Mp(0, inf); return; } void upd(ll id, ll s, ll e, ll l, ll r, pll x){ if(r <= s || e <= l) return; if(l <= s && e <= r){ seg[id] = Do(seg[id], x); return; } ll mid = (s + e) >> 1; shift(id); upd(lc, s, mid, l, r, x); upd(rc, mid, e, l, r, x); return; } void fix(ll id, ll s, ll e){ if(e - s == 1){ ans[s] = seg[id].F; return; } ll mid = (s + e) >> 1; shift(id); fix(lc, s, mid); fix(rc, mid, e); return; } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ fill(seg, seg + (n << 2), Mp(0, inf)); for(ll i = 0; i < k; i++){ if(op[i] == 1){ upd(1, 0, n, left[i], right[i] + 1, Mp(height[i], inf)); } else{ upd(1, 0, n, left[i], right[i] + 1, Mp(0, height[i])); } } fix(1, 0, n); for(ll i = 0; i < n; i++){ finalHeight[i] = ans[i]; } return; } /*int main(){ fast_io; return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...