#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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |