이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ALL(arr) begin(arr), end(arr)
using namespace std;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
// x, ind, end, adding, height
vector<tuple<int, int, bool, int>> addactions;
vector<tuple<int, int, bool, int>> remactions;
for (int i = 0; i < k; i++) {
if (op[i] == 1) {
addactions.push_back({left[i], i, false, height[i]});
addactions.push_back({right[i]+1, i, true, height[i]});
} else {
remactions.push_back({left[i], i, false, height[i]});
remactions.push_back({right[i]+1, i, true, height[i]});
}
}
sort(ALL(addactions));
sort(ALL(remactions));
int px = 0;
multiset<int, greater<int>> prevHeights;
prevHeights.insert(0);
for (auto [x, ind, end, goalheight] : addactions) {
fill(finalHeight + px, finalHeight + x, *prevHeights.begin());
px = x;
if (!end) {
prevHeights.insert(goalheight);
} else {
auto it = prevHeights.find(goalheight);
prevHeights.erase(it);
}
}
fill(finalHeight + px, finalHeight + n, 0);
px = 0;
multiset<int> prevHeights2;
prevHeights2.insert(1e8);
int maxH = 0;
for (auto [x, ind, end, goalheight] : remactions) {
for (int i = px; i < x; i++) {
maxH = finalHeight[i];
finalHeight[i] = min(*prevHeights2.begin(), maxH);
}
px = x;
if (!end) {
prevHeights2.insert(goalheight);
} else {
auto it = prevHeights2.find(goalheight);
prevHeights2.erase(it);
}
}
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |