Submission #306334

#TimeUsernameProblemLanguageResultExecution timeMemory
306334syy벽 (IOI14_wall)C++17
100 / 100
986 ms232440 KiB
#include "wall.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++) #define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--) typedef pair<int, int> pi; #define f first #define s second typedef vector<int> vi; typedef vector<pi> vpi; #define pb push_back #define pf push_front #define all(v) v.begin(), v.end() #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) const int INF = 1e9 + 100; int ans[2000005]; struct node { int s, e, m, vu, vd; node *l, *r; node (int S, int E) { s = S, e = E, m = (s+e)/2, vu = 0, vd = INF; if (s != e) { l = new node(s, m); r = new node(m+1, e); } } void calc(int t, int h) { if (t == 1) { vu = max(vu, h); vd = max(vd, h); } else { vu = min(vu, h); vd = min(vd, h); } } void calcchild() { l->vd = min(l->vd, vd); l->vd = max(l->vd, vu); l->vu = max(l->vu, vu); l->vu = min(l->vu, vd); r->vd = min(r->vd, vd); r->vd = max(r->vd, vu); r->vu = max(r->vu, vu); r->vu = min(r->vu, vd); } void up(int x, int y, int t, int h) { if (s == x and e == y) return calc(t, h); calcchild(); vu = 0, vd = INF; // push previous updates before adding current update if (y <= m) l->up(x, y, t, h); else if (x > m) r->up(x, y, t, h); else l->up(x, m, t, h), r->up(m+1, y, t, h); } void query() { if (s == e) ans[s] = min(vu, vd); else { calcchild(); l->query(), r->query(); } } } *seg; void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { seg = new node(0, n-1); FOR(i, 0, k-1) seg->up(left[i], right[i], op[i], height[i]); seg->query(); FOR(i, 0, n-1) finalHeight[i] = ans[i]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...