# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1241475 | MateiKing80 | 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) {
int rad = -1;
stack<int> s;
for (int i = 0; i < n; i ++) {
left[i] = right[i] = -1;
while (s.size() && query(i, i, s.top(), i)) {
right[s.top()] = left[i];
left[i] = s.top();
s.pop();
}
if (s.size())
right[s.top()] = i;
else
root = i;
s.push(i);
}
return root;
}