# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
776653 |
2023-07-08T06:36:24 Z |
aiyah |
벽 (IOI14_wall) |
C++17 |
|
819 ms |
224548 KB |
#include <bits/stdc++.h>
using namespace std;
int clamp(int val, pair<int,int> bounds) {
return max(bounds.first, min(bounds.second,val));
}
pair<int,int> compose_clamps(pair<int,int> outside, pair<int,int> inside) {
if (outside.second <= inside.first) return {outside.second, outside.second};
if (outside.first >= inside.second) return {outside.first, outside.first};
return {max(outside.first,inside.first), min(outside.second,inside.second)};
}
struct Node {
int l;
int r;
Node *ln;
Node *rn;
pair<int,int> bounds;
Node(int tl, int tr): l(tl), r(tr) {
bounds = {INT_MIN,INT_MAX};
if (l + 1 == r) {
ln = rn = NULL;
return;
}
int mid = (l + r) / 2;
ln = new Node(l, mid);
rn = new Node(mid, r);
}
int get(int i) {
if (l <= i && i < r) {
if (l + 1 == r) {
return clamp(0, bounds);
}
return clamp(ln->get(i) + rn->get(i), bounds);
}
return 0;
}
void avoid_responsibility() {
ln->bounds = compose_clamps(bounds, ln->bounds);
rn->bounds = compose_clamps(bounds, rn->bounds);
bounds = {INT_MIN,INT_MAX};
}
void apply(int lb, int rb, pair<int,int> bds) {
if (rb <= l || r <= lb) return;
if (lb <= l && r <= rb) {
bounds = compose_clamps(bds, bounds);
return;
}
avoid_responsibility();
ln->apply(lb, rb, bds);
rn->apply(lb, rb, bds);
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
Node *root = new Node(0, n);
for (int i = 0; i < k; i++) {
if (op[i] == 1) {
root->apply(left[i], right[i] + 1, {height[i],INT_MAX});
} else {
root->apply(left[i], right[i] + 1, {INT_MIN,height[i]});
}
}
for (int i = 0; i < n; i++) {
finalHeight[i] = root->get(i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
6 ms |
1468 KB |
Output is correct |
5 |
Correct |
5 ms |
1392 KB |
Output is correct |
6 |
Correct |
5 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
101 ms |
13840 KB |
Output is correct |
3 |
Correct |
125 ms |
9128 KB |
Output is correct |
4 |
Correct |
344 ms |
27668 KB |
Output is correct |
5 |
Correct |
197 ms |
28660 KB |
Output is correct |
6 |
Correct |
192 ms |
27120 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 |
6 ms |
1492 KB |
Output is correct |
5 |
Correct |
5 ms |
1436 KB |
Output is correct |
6 |
Correct |
4 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
118 ms |
13876 KB |
Output is correct |
9 |
Correct |
116 ms |
9156 KB |
Output is correct |
10 |
Correct |
343 ms |
27604 KB |
Output is correct |
11 |
Correct |
195 ms |
28668 KB |
Output is correct |
12 |
Correct |
200 ms |
27364 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
107 ms |
13832 KB |
Output is correct |
15 |
Correct |
24 ms |
3076 KB |
Output is correct |
16 |
Correct |
442 ms |
27936 KB |
Output is correct |
17 |
Correct |
200 ms |
27324 KB |
Output is correct |
18 |
Correct |
202 ms |
27328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
1492 KB |
Output is correct |
5 |
Correct |
4 ms |
1456 KB |
Output is correct |
6 |
Correct |
5 ms |
1492 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
100 ms |
13924 KB |
Output is correct |
9 |
Correct |
111 ms |
9036 KB |
Output is correct |
10 |
Correct |
359 ms |
27716 KB |
Output is correct |
11 |
Correct |
195 ms |
28700 KB |
Output is correct |
12 |
Correct |
192 ms |
27100 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
108 ms |
13876 KB |
Output is correct |
15 |
Correct |
25 ms |
3028 KB |
Output is correct |
16 |
Correct |
443 ms |
27880 KB |
Output is correct |
17 |
Correct |
199 ms |
27320 KB |
Output is correct |
18 |
Correct |
200 ms |
27320 KB |
Output is correct |
19 |
Correct |
793 ms |
224524 KB |
Output is correct |
20 |
Correct |
741 ms |
222120 KB |
Output is correct |
21 |
Correct |
755 ms |
224548 KB |
Output is correct |
22 |
Correct |
733 ms |
221924 KB |
Output is correct |
23 |
Correct |
736 ms |
222056 KB |
Output is correct |
24 |
Correct |
745 ms |
222112 KB |
Output is correct |
25 |
Correct |
749 ms |
222064 KB |
Output is correct |
26 |
Correct |
754 ms |
224524 KB |
Output is correct |
27 |
Correct |
740 ms |
224500 KB |
Output is correct |
28 |
Correct |
819 ms |
221960 KB |
Output is correct |
29 |
Correct |
740 ms |
222048 KB |
Output is correct |
30 |
Correct |
790 ms |
221924 KB |
Output is correct |