# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
373721 |
2021-03-05T13:55:05 Z |
Temmie |
벽 (IOI14_wall) |
C++17 |
|
1640 ms |
130028 KB |
#include "wall.h"
#include <bits/stdc++.h>
const int MX = 100000;
struct Node {
Node *l, *r;
int mn, mx;
Node() : l(nullptr), r(nullptr), mn(0), mx(MX) { }
~Node() {
if (l)
delete(l);
if (r)
delete(r);
}
void update() {
if (!l) l = new Node;
if (!r) r = new Node;
mn = std::max(l->mn, r->mn);
mx = std::min(l->mx, r->mx);
if (mn > mx) {
if (l->mn > r->mx)
mn = mx = r->mx;
if (r->mn > l->mx)
mn = mx = r->mn;
}
}
};
Node* head = new Node;
void add(int index, int mn, int mx, int left, int right, Node*& node) {
if (!node)
node = new Node;
if (left == right) {
node->mn = mn;
node->mx = mx;
return;
}
int mid = (left + right) >> 1;
if (mid >= index) add(index, mn, mx, left, mid, node->l);
else add(index, mn, mx, mid + 1, right, node->r);
node->update();
}
struct Operation {
int index;
int mn, mx;
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
std::vector <std::vector <Operation>> operations(n + 1);
for (int i = 0; i < k; i++) {
operations[left[i]].push_back({ i, op[i] == 1 ? height[i] : 0, op[i] == 1 ? MX : height[i] });
operations[right[i] + 1].push_back({ i, 0, MX });
}
for (int i = 0; i < n; i++) {
for (const auto& o : operations[i])
add(o.index, o.mn, o.mx, 0, k - 1, head);
finalHeight[i] = head->mn;
}
delete(head);
}
//int main() {
//int n = 10;
//int k = 6;
//int op[6] = { 1, 0, 0, 1, 1, 0 };
//int left[6] = { 1, 4, 3, 0, 2, 6 };
//int right[6] = { 8, 9, 6, 5, 2, 7 };
//int height[6] = { 4, 1, 5, 3, 5, 0 };
//int finalHeight[10];
//buildWall(n, k, op, left, right, height, finalHeight);
//for (int i = 0; i < n; i++)
//std::cout << finalHeight[i] << " \n"[i == n - 1];
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
876 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
8 ms |
1260 KB |
Output is correct |
5 |
Correct |
7 ms |
1260 KB |
Output is correct |
6 |
Correct |
7 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
348 ms |
51380 KB |
Output is correct |
3 |
Correct |
448 ms |
26220 KB |
Output is correct |
4 |
Correct |
1548 ms |
62464 KB |
Output is correct |
5 |
Correct |
499 ms |
61420 KB |
Output is correct |
6 |
Correct |
491 ms |
60140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
876 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
8 ms |
1260 KB |
Output is correct |
5 |
Correct |
7 ms |
1260 KB |
Output is correct |
6 |
Correct |
7 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
349 ms |
57048 KB |
Output is correct |
9 |
Correct |
503 ms |
27884 KB |
Output is correct |
10 |
Correct |
1566 ms |
70004 KB |
Output is correct |
11 |
Correct |
507 ms |
68588 KB |
Output is correct |
12 |
Correct |
514 ms |
67052 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
384 ms |
57012 KB |
Output is correct |
15 |
Correct |
48 ms |
4972 KB |
Output is correct |
16 |
Correct |
1640 ms |
69892 KB |
Output is correct |
17 |
Correct |
554 ms |
67180 KB |
Output is correct |
18 |
Correct |
564 ms |
67052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
876 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
8 ms |
1260 KB |
Output is correct |
5 |
Correct |
7 ms |
1260 KB |
Output is correct |
6 |
Correct |
8 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
351 ms |
57252 KB |
Output is correct |
9 |
Correct |
468 ms |
28140 KB |
Output is correct |
10 |
Correct |
1487 ms |
69996 KB |
Output is correct |
11 |
Correct |
490 ms |
68716 KB |
Output is correct |
12 |
Correct |
484 ms |
67052 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
380 ms |
57012 KB |
Output is correct |
15 |
Correct |
48 ms |
4972 KB |
Output is correct |
16 |
Correct |
1617 ms |
69972 KB |
Output is correct |
17 |
Correct |
546 ms |
67180 KB |
Output is correct |
18 |
Correct |
551 ms |
67052 KB |
Output is correct |
19 |
Correct |
861 ms |
129896 KB |
Output is correct |
20 |
Correct |
835 ms |
129772 KB |
Output is correct |
21 |
Correct |
843 ms |
129900 KB |
Output is correct |
22 |
Correct |
828 ms |
129772 KB |
Output is correct |
23 |
Correct |
860 ms |
129976 KB |
Output is correct |
24 |
Correct |
850 ms |
129900 KB |
Output is correct |
25 |
Correct |
830 ms |
129960 KB |
Output is correct |
26 |
Correct |
845 ms |
129900 KB |
Output is correct |
27 |
Correct |
844 ms |
129900 KB |
Output is correct |
28 |
Correct |
836 ms |
130028 KB |
Output is correct |
29 |
Correct |
837 ms |
129796 KB |
Output is correct |
30 |
Correct |
849 ms |
129900 KB |
Output is correct |