Submission #106920

# Submission time Handle Problem Language Result Execution time Memory
106920 2019-04-21T05:08:38 Z tjd229 popa (BOI18_popa) C++14
100 / 100
83 ms 432 KB
#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
1 Correct 11 ms 256 KB Output is correct
2 Correct 13 ms 256 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 320 KB Output is correct
2 Correct 66 ms 312 KB Output is correct
3 Correct 37 ms 376 KB Output is correct
4 Correct 46 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 312 KB Output is correct
2 Correct 70 ms 416 KB Output is correct
3 Correct 83 ms 384 KB Output is correct
4 Correct 58 ms 432 KB Output is correct