This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
int solve(int n , int *Left , int *Right) {
stack<int> st;
int root = 0;
for(int i = 0; i < n; ++i)Left[i] = Right[i] = -1;
st.push(0);
for(int i =1; i < n; ++i){
while(st.size() && query(st.top() , i , i , i)){
Right[st.top()] = Left[i];
Left[i] = st.top();
st.pop();
}
if(st.size()) Right[st.top()] = i;
else root = i;
st.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... |