# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
306334 |
2020-09-25T09:07:19 Z |
syy |
벽 (IOI14_wall) |
C++17 |
|
986 ms |
232440 KB |
#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];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
1536 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
6 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
170 ms |
13972 KB |
Output is correct |
3 |
Correct |
183 ms |
9464 KB |
Output is correct |
4 |
Correct |
692 ms |
28152 KB |
Output is correct |
5 |
Correct |
312 ms |
29176 KB |
Output is correct |
6 |
Correct |
298 ms |
27768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
1536 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
6 ms |
1536 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
168 ms |
13948 KB |
Output is correct |
9 |
Correct |
188 ms |
9336 KB |
Output is correct |
10 |
Correct |
680 ms |
28280 KB |
Output is correct |
11 |
Correct |
309 ms |
29176 KB |
Output is correct |
12 |
Correct |
293 ms |
27640 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
169 ms |
13944 KB |
Output is correct |
15 |
Correct |
33 ms |
3192 KB |
Output is correct |
16 |
Correct |
682 ms |
28400 KB |
Output is correct |
17 |
Correct |
305 ms |
27920 KB |
Output is correct |
18 |
Correct |
298 ms |
27896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
1536 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
6 ms |
1536 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
168 ms |
13944 KB |
Output is correct |
9 |
Correct |
179 ms |
9464 KB |
Output is correct |
10 |
Correct |
676 ms |
28152 KB |
Output is correct |
11 |
Correct |
308 ms |
29176 KB |
Output is correct |
12 |
Correct |
304 ms |
27768 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
168 ms |
13940 KB |
Output is correct |
15 |
Correct |
31 ms |
3200 KB |
Output is correct |
16 |
Correct |
680 ms |
28504 KB |
Output is correct |
17 |
Correct |
305 ms |
27896 KB |
Output is correct |
18 |
Correct |
301 ms |
27908 KB |
Output is correct |
19 |
Correct |
964 ms |
232440 KB |
Output is correct |
20 |
Correct |
957 ms |
230008 KB |
Output is correct |
21 |
Correct |
986 ms |
232440 KB |
Output is correct |
22 |
Correct |
960 ms |
229880 KB |
Output is correct |
23 |
Correct |
978 ms |
230056 KB |
Output is correct |
24 |
Correct |
962 ms |
229880 KB |
Output is correct |
25 |
Correct |
978 ms |
230012 KB |
Output is correct |
26 |
Correct |
966 ms |
232440 KB |
Output is correct |
27 |
Correct |
978 ms |
232440 KB |
Output is correct |
28 |
Correct |
960 ms |
229880 KB |
Output is correct |
29 |
Correct |
967 ms |
230008 KB |
Output is correct |
30 |
Correct |
970 ms |
230008 KB |
Output is correct |