Submission #106919

# Submission time Handle Problem Language Result Execution time Memory
106919 2019-04-21T04:40:52 Z tjd229 popa (BOI18_popa) C++14
61 / 100
196 ms 472 KB
#include "popa.h"
int dfs(int l,int r,int *Left,int *Right) {
	//degenerate case
	if (l > r) return -1;
	else if (l == r) {
		Left[l] = Right[l] = -1;
		return l;
	}
	int s = l, e = r;
	int root = -1;
	while (l <= r) {
		int m = (l + r) >> 1;
		if (query(s, e, l, m)) root=m,r = m - 1;
		else l = m + 1;
	}
	//root chk
	Left[root] = dfs(s, root - 1, Left, Right);
	Right[root] = dfs(root+1,e, Left, Right);
	return root;
}
int solve(int N, int *Left, int *Right) {
	return dfs(0, N-1, Left, Right);
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 25 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 17 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 189 ms 412 KB Output is correct
2 Correct 196 ms 472 KB Output is correct
3 Correct 101 ms 420 KB Output is correct
4 Correct 152 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 312 KB too many queries
2 Halted 0 ms 0 KB -