이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "popa.h"
#include <stack>
using namespace std;
int solve(int N, int *Left, int *Right) {
*Left = -1, *Right = -1;
stack<int> stk; stk.push(0);
int root = 0;
for (int i = 1; i < N; ++i) {
Left[i] = Right[i] = -1;
while (stk.size() && query(i,i,stk.top(),i)) {
Right[stk.top()] = Left[i];
Left[i] = stk.top();
stk.pop();
}
if (stk.size()) Right[stk.top()] = i;
else root = i;
stk.push(i);
}
return root;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |