# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
58061 |
2018-07-16T16:51:39 Z |
aome |
벽 (IOI14_wall) |
C++17 |
|
899 ms |
263168 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
struct Node {
int min, max;
Node() { min = 0, max = 1e9; }
Node(int min, int max) : min(min), max(max) {}
};
struct SegmentTree {
Node T[N << 2];
#define mid ((l + r) >> 1)
void upd(int i, int l, int r, int p, Node x) {
if (l == r) {
T[i] = x; return;
}
if (mid >= p) upd(i << 1, l, mid, p, x);
else upd(i << 1 | 1, mid + 1, r, p, x);
T[i].min = max(T[i << 1].min, T[i << 1 | 1].min);
T[i].max = min(T[i << 1].max, T[i << 1 | 1].max);
}
int get1(int i, int l, int r, Node x) {
if (l == r) return l;
Node y;
y.min = max(x.min, T[i << 1 | 1].min);
y.max = min(x.max, T[i << 1 | 1].max);
if (y.min > y.max) {
return get1(i << 1 | 1, mid + 1, r, x);
}
return get1(i << 1, l, mid, y);
}
void get2(int i, int l, int r, int L, int R, Node& x) {
if (l > R || L > r) return;
if (L <= l && r <= R) {
x.min = max(x.min, T[i].min);
x.max = min(x.max, T[i].max);
return;
}
get2(i << 1, l, mid, L, R, x);
get2(i << 1 | 1, mid + 1, r, L, R, x);
}
#undef mid
} IT;
struct Event {
int v, p, x, y, t;
bool operator < (const Event& rhs) const {
return v < rhs.v;
}
};
void buildWall(int n, int m, int op[], int left[], int right[], int height[], int finalHeight[]) {
vector<Event> events;
for (int i = 0; i < m; ++i) {
events.push_back({left[i], i, height[i], op[i], 0});
events.push_back({right[i] + 1, i, height[i], op[i], 1});
}
sort(events.begin(), events.end());
int ptr = 0;
for (int i = 0; i < n; ++i) {
// cout << "#at " << i << '\n';
while (ptr < 2 * m && events[ptr].v <= i) {
if (events[ptr].t == 0) {
if (events[ptr].y == 2) {
// cout << "#add2 " << events[ptr].p << '\n';
IT.upd(1, 0, m - 1, events[ptr].p, Node(0, events[ptr].x));
}
else {
// cout << "#add1 " << events[ptr].p << '\n';
IT.upd(1, 0, m - 1, events[ptr].p, Node(events[ptr].x, 1e9));
}
}
else {
// cout << "#del " << events[ptr].p << '\n';
IT.upd(1, 0, m - 1, events[ptr].p, Node());
}
++ptr;
}
int v, L, R;
if (IT.T[1].min <= IT.T[1].max) {
L = IT.T[1].min, R = IT.T[1].max, v = 0;
}
else {
int p = IT.get1(1, 0, m - 1, Node());
// cout << "#p " << p << '\n';
v = height[p];
Node x = Node();
IT.get2(1, 0, m - 1, p + 1, m - 1, x);
L = x.min, R = x.max;
}
// cout << v << ' ' << L << ' ' << R << '\n';
if (v < L) finalHeight[i] = L;
else if (v > R) finalHeight[i] = R;
else finalHeight[i] = v;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
62968 KB |
Output is correct |
2 |
Correct |
56 ms |
63564 KB |
Output is correct |
3 |
Correct |
53 ms |
63564 KB |
Output is correct |
4 |
Correct |
60 ms |
63676 KB |
Output is correct |
5 |
Correct |
72 ms |
63940 KB |
Output is correct |
6 |
Correct |
58 ms |
63988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
63988 KB |
Output is correct |
2 |
Correct |
428 ms |
92124 KB |
Output is correct |
3 |
Correct |
308 ms |
92124 KB |
Output is correct |
4 |
Correct |
807 ms |
101796 KB |
Output is correct |
5 |
Correct |
558 ms |
112084 KB |
Output is correct |
6 |
Correct |
487 ms |
120588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
120588 KB |
Output is correct |
2 |
Correct |
54 ms |
120588 KB |
Output is correct |
3 |
Correct |
53 ms |
120588 KB |
Output is correct |
4 |
Correct |
57 ms |
120588 KB |
Output is correct |
5 |
Correct |
86 ms |
120588 KB |
Output is correct |
6 |
Correct |
58 ms |
120588 KB |
Output is correct |
7 |
Correct |
54 ms |
120588 KB |
Output is correct |
8 |
Correct |
421 ms |
126740 KB |
Output is correct |
9 |
Correct |
300 ms |
126740 KB |
Output is correct |
10 |
Correct |
761 ms |
140108 KB |
Output is correct |
11 |
Correct |
588 ms |
150472 KB |
Output is correct |
12 |
Correct |
496 ms |
158888 KB |
Output is correct |
13 |
Correct |
50 ms |
158888 KB |
Output is correct |
14 |
Correct |
362 ms |
164832 KB |
Output is correct |
15 |
Correct |
88 ms |
164832 KB |
Output is correct |
16 |
Correct |
792 ms |
175244 KB |
Output is correct |
17 |
Correct |
538 ms |
184124 KB |
Output is correct |
18 |
Correct |
514 ms |
193116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
193116 KB |
Output is correct |
2 |
Correct |
56 ms |
193116 KB |
Output is correct |
3 |
Correct |
64 ms |
193116 KB |
Output is correct |
4 |
Correct |
67 ms |
193116 KB |
Output is correct |
5 |
Correct |
69 ms |
193116 KB |
Output is correct |
6 |
Correct |
60 ms |
193116 KB |
Output is correct |
7 |
Correct |
54 ms |
193116 KB |
Output is correct |
8 |
Correct |
544 ms |
199356 KB |
Output is correct |
9 |
Correct |
461 ms |
199356 KB |
Output is correct |
10 |
Correct |
772 ms |
212816 KB |
Output is correct |
11 |
Correct |
537 ms |
222796 KB |
Output is correct |
12 |
Correct |
516 ms |
231448 KB |
Output is correct |
13 |
Correct |
51 ms |
231448 KB |
Output is correct |
14 |
Correct |
424 ms |
237376 KB |
Output is correct |
15 |
Correct |
102 ms |
237376 KB |
Output is correct |
16 |
Correct |
899 ms |
247572 KB |
Output is correct |
17 |
Correct |
581 ms |
256600 KB |
Output is correct |
18 |
Runtime error |
602 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
19 |
Halted |
0 ms |
0 KB |
- |