Submission #466082

# Submission time Handle Problem Language Result Execution time Memory
466082 2021-08-17T21:40:23 Z nickmet2004 popa (BOI18_popa) C++11
100 / 100
113 ms 400 KB
#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
1 Correct 6 ms 200 KB Output is correct
2 Correct 11 ms 200 KB Output is correct
3 Correct 11 ms 200 KB Output is correct
4 Correct 11 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 292 KB Output is correct
2 Correct 111 ms 280 KB Output is correct
3 Correct 81 ms 200 KB Output is correct
4 Correct 87 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 200 KB Output is correct
2 Correct 90 ms 400 KB Output is correct
3 Correct 58 ms 280 KB Output is correct
4 Correct 99 ms 280 KB Output is correct