# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
306334 | | syy | Wall (IOI14_wall) | C++17 | | 986 ms | 232440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |