/// hhoangcpascal
#include <cstdio>
#include <iostream>
#include <algorithm>
#define file_name "WALL"
using namespace std;
struct node {
int mmin, mmax;
} Seg[8000006];
void update(int id, int val, int type) {
if (type == 2) {
Seg[id].mmax = min(Seg[id].mmax, val);
Seg[id].mmin = min(Seg[id].mmin, val);
} else {
Seg[id].mmax = max(Seg[id].mmax, val);
Seg[id].mmin = max(Seg[id].mmin, val);
}
}
void down(int id) {
Seg[id<<1].mmax = max(min(Seg[id<<1].mmax, Seg[id].mmax), Seg[id].mmin);
Seg[id<<1].mmin = min(max(Seg[id<<1].mmin, Seg[id].mmin), Seg[id].mmax);
Seg[id<<1|1].mmax = max(min(Seg[id<<1|1].mmax, Seg[id].mmax), Seg[id].mmin);
Seg[id<<1|1].mmin = min(max(Seg[id<<1|1].mmin, Seg[id].mmin), Seg[id].mmax);
Seg[id].mmax = 1e9, Seg[id].mmin = 0;
}
void update(int id, int l, int r, int u, int v, int val, int type) {
if (l > v || r < u) return;
if (u <= l && r <= v) {
update(id, val, type);
return;
}
int mid = (l + r) >> 1;
down(id);
update(id<<1, l, mid, u, v, val, type);
update(id<<1|1, mid+1, r, u, v, val, type);
}
int ans[2000006];
void cal(int id, int l, int r) {
if (l > r) return;
if (l == r) {
ans[l] = Seg[id].mmin;
return;
}
int mid = (l + r) >> 1;
down(id);
cal(id<<1, l, mid);
cal(id<<1|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)
update(1, 1, n, Left[i]+1, Right[i]+1, height[i], op[i]);
cal(1, 1, n);
for(int i=0; i<n; ++i) finalHeight[i] = ans[i+1];
}
# |
결과 |
실행 시간 |
메모리 |
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 |
6 ms |
896 KB |
Output is correct |
5 |
Correct |
6 ms |
896 KB |
Output is correct |
6 |
Correct |
6 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
174 ms |
13944 KB |
Output is correct |
3 |
Correct |
189 ms |
8056 KB |
Output is correct |
4 |
Correct |
527 ms |
20856 KB |
Output is correct |
5 |
Correct |
345 ms |
21880 KB |
Output is correct |
6 |
Correct |
327 ms |
20280 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 |
6 ms |
928 KB |
Output is correct |
5 |
Correct |
6 ms |
896 KB |
Output is correct |
6 |
Correct |
6 ms |
896 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
174 ms |
13944 KB |
Output is correct |
9 |
Correct |
189 ms |
8060 KB |
Output is correct |
10 |
Correct |
530 ms |
20856 KB |
Output is correct |
11 |
Correct |
344 ms |
21872 KB |
Output is correct |
12 |
Correct |
326 ms |
20344 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
178 ms |
13944 KB |
Output is correct |
15 |
Correct |
31 ms |
2176 KB |
Output is correct |
16 |
Correct |
518 ms |
21112 KB |
Output is correct |
17 |
Correct |
329 ms |
20600 KB |
Output is correct |
18 |
Correct |
332 ms |
20472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
544 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
896 KB |
Output is correct |
5 |
Correct |
6 ms |
896 KB |
Output is correct |
6 |
Correct |
6 ms |
896 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
174 ms |
14040 KB |
Output is correct |
9 |
Correct |
183 ms |
8116 KB |
Output is correct |
10 |
Correct |
524 ms |
20856 KB |
Output is correct |
11 |
Correct |
336 ms |
21880 KB |
Output is correct |
12 |
Correct |
323 ms |
20344 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
179 ms |
14020 KB |
Output is correct |
15 |
Correct |
30 ms |
2168 KB |
Output is correct |
16 |
Correct |
521 ms |
21240 KB |
Output is correct |
17 |
Correct |
328 ms |
20472 KB |
Output is correct |
18 |
Correct |
328 ms |
20512 KB |
Output is correct |
19 |
Correct |
770 ms |
77488 KB |
Output is correct |
20 |
Correct |
766 ms |
75000 KB |
Output is correct |
21 |
Correct |
775 ms |
77432 KB |
Output is correct |
22 |
Correct |
766 ms |
75000 KB |
Output is correct |
23 |
Correct |
801 ms |
74880 KB |
Output is correct |
24 |
Correct |
771 ms |
74872 KB |
Output is correct |
25 |
Correct |
767 ms |
74872 KB |
Output is correct |
26 |
Correct |
774 ms |
77648 KB |
Output is correct |
27 |
Correct |
775 ms |
77680 KB |
Output is correct |
28 |
Correct |
762 ms |
75080 KB |
Output is correct |
29 |
Correct |
791 ms |
74872 KB |
Output is correct |
30 |
Correct |
762 ms |
74872 KB |
Output is correct |