Submission #466082

#TimeUsernameProblemLanguageResultExecution timeMemory
466082nickmet2004popa (BOI18_popa)C++11
100 / 100
113 ms400 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...