#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1 << 21;
struct SegTree {
int seg[N];
int n;
SegTree(int n) : n(n) {}
void update(int l, int r, int h, bool op) {
l += n;
r += n;
while (r > l) {
if (l & 1) {
if (op) {
seg[l] = max(seg[l], h);
} else {
seg[l] = min(seg[l], h);
}
l++;
}
if (r & 1) {
r--;
if (op) {
seg[r] = max(seg[r], h);
} else {
seg[r] = min(seg[r], h);
}
}
l /= 2;
r /= 2;
}
}
int query(int i) { return seg[n + i]; }
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[],
int finalHeight[]) {
SegTree tr(n);
for (int i = 0; i < k; ++i) {
tr.update(left[i], right[i] + 1, height[i], op[i] == 1);
}
for (int i = 0; i < n; ++i) {
finalHeight[i] = tr.query(i);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8792 KB |
Output is correct |
2 |
Correct |
5 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
8 ms |
8540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8540 KB |
Output is correct |
2 |
Correct |
88 ms |
22100 KB |
Output is correct |
3 |
Incorrect |
73 ms |
15700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8536 KB |
Output is correct |
2 |
Correct |
5 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
4 ms |
8564 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8540 KB |
Output is correct |
2 |
Correct |
5 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
5 ms |
8540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |