이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FOR(i, x, y) for (int i = x; i < y ; i ++)
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
vector<pair<int,ii>> phases;
int num_add = 0;
while(num_add < k && op[num_add] == 1 ){
phases.PB(MP(left[num_add], MP(height[num_add], right[num_add])));
num_add ++;
}
sort(phases.begin(), phases.end());
int i_phase = 0;
priority_queue<ii> ranges; // (height, right)
vi arr(n, 0);
FOR(i, 0, n){
while(i_phase < num_add && i == phases[i_phase].first){
ranges.push(phases[i_phase].second);
i_phase ++;
}
while(!ranges.empty() && ranges.top().second < i){
ranges.pop();
}
if (ranges.empty()) arr[i] = 0;
else arr[i] = ranges.top().first;
}
phases.clear();
FOR(i, num_add, k){
cout <<left[i] << ' ' << right[i]<< '\n';
phases.PB(MP(left[i], MP(-height[i], right[i])));
}
sort(phases.begin(), phases.end());
priority_queue<ii> Ranges; // (height, right)
i_phase = 0;
FOR(i, 0, n){
while(i_phase < (k -num_add) && i == phases[i_phase].first){
Ranges.push(phases[i_phase].second);
i_phase ++;
}
while(!Ranges.empty() && Ranges.top().second < i){
Ranges.pop();
}
if (!Ranges.empty()) arr[i] = min(arr[i], -Ranges.top().first);
}
FOR(i, 0, n){
finalHeight[i] = arr[i];
//cout << finalHeight[i] << ' ';
}
}
# | 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... |