# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
428737 |
2021-06-15T14:08:59 Z |
_ani |
벽 (IOI14_wall) |
C++17 |
|
1744 ms |
99324 KB |
#include "wall.h"
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2'000'002;
int add[4 * maxn], sub[4 * maxn];
void Comp(int v, int h, int t)
{
if (h == -1) return;
if (add[v] == -1 && sub[v] == -1)
{
if (t == 1) add[v] = h;
else sub[v] = h;
return;
}
if (t == 1 && add[v] != -1)
{
add[v] = max(add[v], h);
if (sub[v] != -1 && sub[v] < add[v])
sub[v] = add[v];
return;
}
if (t == 2 && sub[v] != -1)
{
sub[v] = min(sub[v], h);
if (add[v] != -1 && sub[v] < add[v])
add[v] = sub[v];
return;
}
if (t == 1)
{
if (h >= sub[v])
{
sub[v] = add[v] = h;
return;
}
add[v] = h;
return;
}
if (h <= add[v])
{
sub[v] = add[v] = h;
return;
}
sub[v] = h;
return;
}
void Push(int v)
{
Comp(v * 2, add[v], 1);
Comp(v * 2, sub[v], 2);
Comp(v * 2 + 1, add[v], 1);
Comp(v * 2 + 1, sub[v], 2);
add[v] = sub[v] = -1;
}
void Upd(int v, int vl, int vr, int l, int r, int h, int t)
{
if (r < l) return;
if (vl == l && vr == r)
{
Comp(v, h, t);
return;
}
int m = (vl + vr) / 2;
Push(v);
Upd(v * 2, vl, m, l, min(m, r), h, t);
Upd(v * 2 + 1, m + 1, vr, max(l, m + 1), r, h, t);
}
pair<int, int> Get(int v, int vl, int vr, int pos)
{
if (vl == vr)
return {add[v], sub[v]};
int m = (vl + vr) / 2;
Push(v);
if (pos <= m)
return Get(v * 2, vl, m, pos);
else return Get(v * 2 + 1, m + 1, vr, pos);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i = 0; i < 4 * maxn; i++)
sub[i] = add[i] = -1;
for (int i = 0; i < k; i++)
Upd(1, 0, n - 1, left[i], right[i], height[i], op[i]);
fill(finalHeight, finalHeight + n, 0);
for (int i = 0; i < n; i++)
{
auto x = Get(1, 0, n - 1, i);
if (x.first == -1 && x.second == -1)
continue;
if (x.first != -1 && x.second != -1)
{
if (finalHeight[i] <= x.first)
finalHeight[i] = x.first;
else finalHeight[i] = x.second;
continue;
}
if (x.first != -1 && finalHeight[i] <= x.first)
finalHeight[i] = x.first;
if (x.second != -1 && finalHeight[i] > x.second)
finalHeight[i] = x.second;
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
62796 KB |
Output is correct |
2 |
Correct |
31 ms |
62984 KB |
Output is correct |
3 |
Correct |
32 ms |
62920 KB |
Output is correct |
4 |
Correct |
43 ms |
62968 KB |
Output is correct |
5 |
Correct |
42 ms |
62992 KB |
Output is correct |
6 |
Correct |
41 ms |
62984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
62872 KB |
Output is correct |
2 |
Correct |
233 ms |
70668 KB |
Output is correct |
3 |
Correct |
273 ms |
66248 KB |
Output is correct |
4 |
Correct |
827 ms |
71260 KB |
Output is correct |
5 |
Correct |
505 ms |
71772 KB |
Output is correct |
6 |
Correct |
455 ms |
71768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
62868 KB |
Output is correct |
2 |
Correct |
35 ms |
62916 KB |
Output is correct |
3 |
Correct |
34 ms |
62828 KB |
Output is correct |
4 |
Correct |
39 ms |
63008 KB |
Output is correct |
5 |
Correct |
35 ms |
63060 KB |
Output is correct |
6 |
Correct |
37 ms |
63000 KB |
Output is correct |
7 |
Correct |
33 ms |
62880 KB |
Output is correct |
8 |
Correct |
197 ms |
70632 KB |
Output is correct |
9 |
Correct |
299 ms |
66180 KB |
Output is correct |
10 |
Correct |
894 ms |
71264 KB |
Output is correct |
11 |
Correct |
470 ms |
71776 KB |
Output is correct |
12 |
Correct |
418 ms |
71808 KB |
Output is correct |
13 |
Correct |
31 ms |
62832 KB |
Output is correct |
14 |
Correct |
210 ms |
70672 KB |
Output is correct |
15 |
Correct |
90 ms |
63520 KB |
Output is correct |
16 |
Correct |
1000 ms |
71524 KB |
Output is correct |
17 |
Correct |
475 ms |
71516 KB |
Output is correct |
18 |
Correct |
511 ms |
71516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
62848 KB |
Output is correct |
2 |
Correct |
29 ms |
62940 KB |
Output is correct |
3 |
Correct |
30 ms |
62932 KB |
Output is correct |
4 |
Correct |
37 ms |
63032 KB |
Output is correct |
5 |
Correct |
34 ms |
63044 KB |
Output is correct |
6 |
Correct |
37 ms |
62992 KB |
Output is correct |
7 |
Correct |
32 ms |
62820 KB |
Output is correct |
8 |
Correct |
213 ms |
70704 KB |
Output is correct |
9 |
Correct |
305 ms |
66340 KB |
Output is correct |
10 |
Correct |
750 ms |
71372 KB |
Output is correct |
11 |
Correct |
485 ms |
71844 KB |
Output is correct |
12 |
Correct |
475 ms |
71876 KB |
Output is correct |
13 |
Correct |
30 ms |
62860 KB |
Output is correct |
14 |
Correct |
202 ms |
70772 KB |
Output is correct |
15 |
Correct |
76 ms |
63596 KB |
Output is correct |
16 |
Correct |
1110 ms |
71644 KB |
Output is correct |
17 |
Correct |
507 ms |
71936 KB |
Output is correct |
18 |
Correct |
461 ms |
71940 KB |
Output is correct |
19 |
Correct |
1744 ms |
89220 KB |
Output is correct |
20 |
Correct |
1525 ms |
96752 KB |
Output is correct |
21 |
Correct |
1560 ms |
99324 KB |
Output is correct |
22 |
Correct |
1492 ms |
96764 KB |
Output is correct |
23 |
Correct |
1486 ms |
96680 KB |
Output is correct |
24 |
Correct |
1519 ms |
96796 KB |
Output is correct |
25 |
Correct |
1528 ms |
96776 KB |
Output is correct |
26 |
Correct |
1505 ms |
99240 KB |
Output is correct |
27 |
Correct |
1539 ms |
99244 KB |
Output is correct |
28 |
Correct |
1591 ms |
96748 KB |
Output is correct |
29 |
Correct |
1516 ms |
96796 KB |
Output is correct |
30 |
Correct |
1620 ms |
96720 KB |
Output is correct |