# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1162681 | brinton | 도로 폐쇄 (APIO21_roads) | C++20 | 0 ms | 0 KiB |
#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000
vector<vector<int>> edges;
vector<int> H;
vector<vector<int>> big,small;
int N;
int k;
void init(int iN, std::vector<int> iH) {
N = iN;
H = iH;
// create DAG using monotic array
stack<int> st;
edges.resize(N+1);
// create front
for(int i = 0;i < N;i++){
while(!st.empty() && st.top() < H[i]){
st.pop();
}
if(!st.empty()){
edges[H[i]].push_back(st.top());
}
st.push(H[i]);
}
while(!st.empty()) st.pop();
// from back