Submission #593606

#TimeUsernameProblemLanguageResultExecution timeMemory
593606VanillaWall (IOI14_wall)C++17
61 / 100
426 ms48592 KiB
#include <bits/stdc++.h> #include "wall.h" using namespace std; const int maxn = 2e6 + 1; struct node { int mn = 1e9; int mx = 0; void propagate (node &p1, node &p2) { p1.merge(mn, mx); p2.merge(mn, mx); mn = 1e9, mx = 0; } void merge (const int &mn2, const int &mx2) { mn = min(mn, mn2); mx = max(min(mn2, mx), mx2); } void operator= (const pair <int, int> &x) { mn = x.first, mx = x.second; } } sgt [maxn * 2]; void upd (int x, int l, int r, int il, int ir, int h, int op) { if (l > ir || r < il) return; if (il <= l && r <= ir) { if (op == 1) sgt[x].merge(1e9, h); else sgt[x].merge(h, 0); return; } sgt[x].propagate(sgt[x * 2], sgt[x * 2 + 1]); int mid = (l + r) / 2; upd(x * 2, l, mid, il, ir, h, op); upd(x * 2 + 1, mid + 1, r, il, ir, h, op); } void get (int x, int l, int r, int a[]){ if (l > r) return; if (l == r) { a[l] = sgt[x].mx; return; } sgt[x].propagate(sgt[x * 2], sgt[x * 2 + 1]); int mid = (l + r) / 2; get(x * 2, l, mid, a); get(x * 2 + 1, mid + 1, r, a); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ ios_base::sync_with_stdio(0); cin.tie(0); for (int i = 0; i < k; i++){ upd(1, 0, n-1, left[i], right[i], height[i], op[i]); } get(1, 0, n-1, finalHeight); 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...