#include <iostream>
using namespace std;
const int inf = 1e9, N = 1 << 22;
int mx[N], mn[N];
void change(int v, int d, int u) {
mn[v] = max(u, min(d, mn[v]));
mx[v] = min(d, max(u, mx[v]));
}
void push(int v) {
change(v << 1|0, mn[v], mx[v]);
change(v << 1|1, mn[v], mx[v]);
mx[v] = 0; mn[v] = inf;
}
int d, u, lo, hi;
void update(int v, int l, int r) {
if (hi <= l || r <= lo) return;
if (lo <= l && r <= hi) return change(v, d, u);
push(v); int m = (l + r) / 2;
update(v << 1|0, l, m);
update(v << 1|1, m, r);
}
void final(int ans[], int v, int l, int r) {
if (r - l == 1)
return void(ans[l] = min(mx[v], mn[v]));
push(v); int m = (l + r) / 2;
final(ans, v << 1|0, l, m);
final(ans, v << 1|1, m, r);
}
void buildWall(int n, int q, int op[], int l[], int r[], int h[], int ans[]) {
for (int i = 0; i < N; ++i) mn[i] = inf, mx[i] = 0;
for (int i = 0; i < q; ++i) {
u = 0; d = inf;
lo = l[i]; hi = r[i] + 1;
op[i] != 1 ? d = h[i]: u = h[i];
update(1, 0, n);
}
final(ans, 1, 0, n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
33152 KB |
Output is correct |
2 |
Correct |
24 ms |
33280 KB |
Output is correct |
3 |
Correct |
27 ms |
33152 KB |
Output is correct |
4 |
Correct |
28 ms |
33408 KB |
Output is correct |
5 |
Correct |
27 ms |
33408 KB |
Output is correct |
6 |
Correct |
27 ms |
33408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
33152 KB |
Output is correct |
2 |
Correct |
200 ms |
41080 KB |
Output is correct |
3 |
Correct |
196 ms |
39032 KB |
Output is correct |
4 |
Correct |
498 ms |
43128 KB |
Output is correct |
5 |
Correct |
341 ms |
43616 KB |
Output is correct |
6 |
Correct |
338 ms |
44408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
33144 KB |
Output is correct |
2 |
Correct |
25 ms |
33280 KB |
Output is correct |
3 |
Correct |
27 ms |
33256 KB |
Output is correct |
4 |
Correct |
27 ms |
33408 KB |
Output is correct |
5 |
Correct |
32 ms |
33404 KB |
Output is correct |
6 |
Correct |
27 ms |
33408 KB |
Output is correct |
7 |
Correct |
22 ms |
33152 KB |
Output is correct |
8 |
Correct |
202 ms |
44500 KB |
Output is correct |
9 |
Correct |
201 ms |
39928 KB |
Output is correct |
10 |
Correct |
492 ms |
44224 KB |
Output is correct |
11 |
Correct |
337 ms |
44152 KB |
Output is correct |
12 |
Correct |
314 ms |
44920 KB |
Output is correct |
13 |
Correct |
22 ms |
33152 KB |
Output is correct |
14 |
Correct |
199 ms |
43640 KB |
Output is correct |
15 |
Correct |
50 ms |
34296 KB |
Output is correct |
16 |
Correct |
504 ms |
43256 KB |
Output is correct |
17 |
Correct |
334 ms |
43768 KB |
Output is correct |
18 |
Correct |
331 ms |
43596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
33152 KB |
Output is correct |
2 |
Correct |
25 ms |
33280 KB |
Output is correct |
3 |
Correct |
23 ms |
33152 KB |
Output is correct |
4 |
Correct |
29 ms |
33408 KB |
Output is correct |
5 |
Correct |
27 ms |
33408 KB |
Output is correct |
6 |
Correct |
26 ms |
33408 KB |
Output is correct |
7 |
Correct |
22 ms |
33128 KB |
Output is correct |
8 |
Correct |
198 ms |
43384 KB |
Output is correct |
9 |
Correct |
193 ms |
39032 KB |
Output is correct |
10 |
Correct |
487 ms |
43088 KB |
Output is correct |
11 |
Correct |
328 ms |
43512 KB |
Output is correct |
12 |
Correct |
318 ms |
44408 KB |
Output is correct |
13 |
Correct |
22 ms |
33152 KB |
Output is correct |
14 |
Correct |
201 ms |
43512 KB |
Output is correct |
15 |
Correct |
58 ms |
34424 KB |
Output is correct |
16 |
Correct |
492 ms |
43256 KB |
Output is correct |
17 |
Correct |
325 ms |
43768 KB |
Output is correct |
18 |
Correct |
321 ms |
43640 KB |
Output is correct |
19 |
Correct |
678 ms |
60536 KB |
Output is correct |
20 |
Correct |
667 ms |
58228 KB |
Output is correct |
21 |
Correct |
685 ms |
60536 KB |
Output is correct |
22 |
Correct |
663 ms |
58108 KB |
Output is correct |
23 |
Correct |
681 ms |
58104 KB |
Output is correct |
24 |
Correct |
665 ms |
58184 KB |
Output is correct |
25 |
Correct |
668 ms |
57868 KB |
Output is correct |
26 |
Correct |
669 ms |
60408 KB |
Output is correct |
27 |
Correct |
692 ms |
60408 KB |
Output is correct |
28 |
Correct |
668 ms |
57848 KB |
Output is correct |
29 |
Correct |
671 ms |
57848 KB |
Output is correct |
30 |
Correct |
669 ms |
57848 KB |
Output is correct |