#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
const int N = 2e6 + 5, inf = 1e9;
struct node{
int l, r;
} lazy[4 * N];
void down(node &a, node b) {
if(a.l >= b.r) {
a = {b.r, b.r};
return;
}
if(a.r <= b.l) {
a = {b.l, b.l};
return;
}
a.l = max(a.l, b.l); a.r = min(a.r, b.r);
assert(a.l <= a.r);
}
void push(int u, int l,int r) {
if(lazy[u].l == 0 && lazy[u].r == inf) return;
if(l == r) return;
down(lazy[2 * u], lazy[u]);
down(lazy[2 * u + 1], lazy[u]);
lazy[u] = {0, inf};
}
void upd(int u, int st, int en, int l,int r, int v, int t) {
push(u, l, r);
if(l > en || r < st) return;
if(st <= l && r <= en) {
if(l == r) {
if(!t) {
lazy[u].l = max(lazy[u].l, v);
lazy[u].r = max(lazy[u].r, v);
}
else {
lazy[u].l = min(lazy[u].l, v);
lazy[u].r = min(lazy[u].r, v);
}
return;
}
if(!t) lazy[u].l = v;
else lazy[u].r = v;
push(u, l, r);
return;
}
int mid = (l + r) >> 1;
upd(2 * u, st, en, l, mid, v, t);
upd(2 * u + 1,st, en, mid + 1, r, v,t);
}
int get(int u,int ind, int l,int r){
push(u, l, r);
if(l == r) return lazy[u].l;
int mid = (l + r) / 2;
if(ind <= mid) return get(2 * u, ind, l, mid);
else return get(2 * u + 1, ind, mid + 1, r);
}
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int ih[]){
for(int i = 1; i <= 4 * n; i++) lazy[i] = {0, inf};
--n;
for(int i = 0; i < k; i++) {
upd(1, l[i], r[i], 0, n, h[i], --op[i]);
}
for(int i = 0; i <= n; i++) {
ih[i] = get(1, i, 0, n);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
852 KB |
Output is correct |
5 |
Correct |
5 ms |
836 KB |
Output is correct |
6 |
Correct |
6 ms |
832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
140 ms |
13904 KB |
Output is correct |
3 |
Correct |
233 ms |
7936 KB |
Output is correct |
4 |
Correct |
556 ms |
21392 KB |
Output is correct |
5 |
Correct |
295 ms |
22472 KB |
Output is correct |
6 |
Correct |
297 ms |
21020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
444 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
816 KB |
Output is correct |
5 |
Correct |
6 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
852 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
142 ms |
13880 KB |
Output is correct |
9 |
Correct |
200 ms |
8012 KB |
Output is correct |
10 |
Correct |
611 ms |
21488 KB |
Output is correct |
11 |
Correct |
284 ms |
22504 KB |
Output is correct |
12 |
Correct |
324 ms |
20936 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
141 ms |
13856 KB |
Output is correct |
15 |
Correct |
40 ms |
2024 KB |
Output is correct |
16 |
Correct |
763 ms |
21776 KB |
Output is correct |
17 |
Correct |
292 ms |
21084 KB |
Output is correct |
18 |
Correct |
294 ms |
21100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
824 KB |
Output is correct |
5 |
Correct |
6 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
143 ms |
13932 KB |
Output is correct |
9 |
Correct |
220 ms |
8092 KB |
Output is correct |
10 |
Correct |
584 ms |
21416 KB |
Output is correct |
11 |
Correct |
294 ms |
22528 KB |
Output is correct |
12 |
Correct |
330 ms |
20932 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
134 ms |
13900 KB |
Output is correct |
15 |
Correct |
50 ms |
2036 KB |
Output is correct |
16 |
Correct |
753 ms |
21708 KB |
Output is correct |
17 |
Correct |
292 ms |
21216 KB |
Output is correct |
18 |
Correct |
330 ms |
21188 KB |
Output is correct |
19 |
Correct |
939 ms |
99320 KB |
Output is correct |
20 |
Correct |
962 ms |
96712 KB |
Output is correct |
21 |
Correct |
957 ms |
99240 KB |
Output is correct |
22 |
Correct |
935 ms |
96800 KB |
Output is correct |
23 |
Correct |
993 ms |
96712 KB |
Output is correct |
24 |
Correct |
933 ms |
96760 KB |
Output is correct |
25 |
Correct |
964 ms |
96800 KB |
Output is correct |
26 |
Correct |
945 ms |
99392 KB |
Output is correct |
27 |
Correct |
963 ms |
99228 KB |
Output is correct |
28 |
Correct |
974 ms |
96776 KB |
Output is correct |
29 |
Correct |
978 ms |
96724 KB |
Output is correct |
30 |
Correct |
942 ms |
96696 KB |
Output is correct |