# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
919839 |
2024-02-01T17:32:49 Z |
Macker |
벽 (IOI14_wall) |
C++17 |
|
598 ms |
86104 KB |
#include <wall.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
struct node{
int mx = INT_MAX, mn = 0;
int val = 0;
};
vector<node> st;
int len = 1;
void prop(int i){
node& n = st[i], &l = st[i * 2], &r = st[i * 2 + 1];
smin(l.mx, n.mx); smax(l.mx, n.mn);
smax(l.mn, n.mn); smin(l.mn, n.mx);
smin(l.val, n.mx); smax(l.val, n.mn);
smin(r.mx, n.mx); smax(r.mx, n.mn);
smax(r.mn, n.mn); smin(r.mn, n.mx);
smin(r.val, n.mx); smax(r.val, n.mn);
n.mx = INT_MAX;
n.mn = 0;
}
void upd(int l, int r, int mx, int mn, int i = 1, int s = 0, int e = len){
if(e <= l || s >= r) return;
if(l <= s && e <= r){
smin(st[i].mx, mx); smax(st[i].mx, mn);
smax(st[i].mn, mn); smin(st[i].mn, mx);
smin(st[i].val, mx); smax(st[i].val, mn);
return;
}
prop(i);
upd(l, r, mx, mn, i * 2, s, (s + e) / 2);
upd(l, r, mx, mn, i * 2 + 1, (s + e) / 2, e);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
while(len < n) len *= 2;
st.resize(2 * len);
for (int i = 0; i < k; i++) {
int mx = INT_MAX, mn = 0;
if(op[i] == 1) mn = height[i];
else mx = height[i];
upd(left[i], right[i] + 1, mx, mn);
}
for (int i = 1; i < len; i++) {
prop(i);
}
for (int i = len; i < len + n; i++) {
finalHeight[i - len] = st[i].val;
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
856 KB |
Output is correct |
5 |
Correct |
4 ms |
936 KB |
Output is correct |
6 |
Correct |
5 ms |
1112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
103 ms |
13904 KB |
Output is correct |
3 |
Correct |
154 ms |
8272 KB |
Output is correct |
4 |
Correct |
412 ms |
21328 KB |
Output is correct |
5 |
Correct |
252 ms |
22352 KB |
Output is correct |
6 |
Correct |
249 ms |
20832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
4 ms |
856 KB |
Output is correct |
6 |
Correct |
4 ms |
856 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
102 ms |
13904 KB |
Output is correct |
9 |
Correct |
148 ms |
8272 KB |
Output is correct |
10 |
Correct |
414 ms |
21488 KB |
Output is correct |
11 |
Correct |
253 ms |
22548 KB |
Output is correct |
12 |
Correct |
251 ms |
20988 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
105 ms |
13908 KB |
Output is correct |
15 |
Correct |
24 ms |
2384 KB |
Output is correct |
16 |
Correct |
422 ms |
21584 KB |
Output is correct |
17 |
Correct |
248 ms |
21096 KB |
Output is correct |
18 |
Correct |
248 ms |
21172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
856 KB |
Output is correct |
5 |
Correct |
4 ms |
856 KB |
Output is correct |
6 |
Correct |
5 ms |
856 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
103 ms |
13908 KB |
Output is correct |
9 |
Correct |
147 ms |
8320 KB |
Output is correct |
10 |
Correct |
418 ms |
21584 KB |
Output is correct |
11 |
Correct |
258 ms |
22416 KB |
Output is correct |
12 |
Correct |
249 ms |
21024 KB |
Output is correct |
13 |
Correct |
0 ms |
600 KB |
Output is correct |
14 |
Correct |
104 ms |
14052 KB |
Output is correct |
15 |
Correct |
24 ms |
2384 KB |
Output is correct |
16 |
Correct |
415 ms |
21584 KB |
Output is correct |
17 |
Correct |
249 ms |
21064 KB |
Output is correct |
18 |
Correct |
248 ms |
21168 KB |
Output is correct |
19 |
Correct |
576 ms |
85868 KB |
Output is correct |
20 |
Correct |
579 ms |
83332 KB |
Output is correct |
21 |
Correct |
584 ms |
85964 KB |
Output is correct |
22 |
Correct |
573 ms |
83792 KB |
Output is correct |
23 |
Correct |
572 ms |
83536 KB |
Output is correct |
24 |
Correct |
579 ms |
83540 KB |
Output is correct |
25 |
Correct |
578 ms |
83676 KB |
Output is correct |
26 |
Correct |
598 ms |
85892 KB |
Output is correct |
27 |
Correct |
589 ms |
86104 KB |
Output is correct |
28 |
Correct |
578 ms |
83392 KB |
Output is correct |
29 |
Correct |
583 ms |
83536 KB |
Output is correct |
30 |
Correct |
583 ms |
83524 KB |
Output is correct |