# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1269847 | glupan | popa (BOI18_popa) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
int solve(int N, int* Left, int* Right) {
stack<int>s;
s.push(0);
for(int i=0; i<N; i++) {
Left[i] = -1;
Right[i] = -1;
}
for(int i=1; i<N; i++) {
int last=-1;
while(s.size() and query(s.top(), i, i, i)) {
prev=s.top();
s.pop();
}
Left[i] = prev;
if(s.size()) Right[s.top()] = i;
s.push(i);
}
while(s.size() > 1) s.pop();
return s.top();
}