Submission #593572

#TimeUsernameProblemLanguageResultExecution timeMemory
593572VanillaWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "wall.h" using namespace std; const int maxn = 2e6 + 2; int rs [maxn]; 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 (int mn2, 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 [4 * maxn]; 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){ if (l > r) return; if (l == r) { rs[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); get(x * 2 + 1, mid + 1, r); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ 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); for (int i = 0; i < n; i++) finalHeight[i] = rs[i]; return; }

Compilation message (stderr)

Compilation timeout while compiling wall