#include "popa.h"
int P[1000];
int solve(int N, int* L, int* R) {
int root = -1;
for (int i = 0; i < N; i++) {
L[i] = R[i] = P[i] = -1;
int par = i - 1;
while (par != -1 && query(i, i, par, i)) {
R[par] = L[i];
P[L[i]] = par;
L[i] = par;
int parpar = P[par];
P[par] = i;
par = parpar;
}
if (par == -1) {
L[i] = root;
if (root != -1) P[root] = i;
root = i;
} else {
R[par] = i;
P[i] = par;
}
}
return root;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
248 KB |
Output is correct |
2 |
Correct |
17 ms |
248 KB |
Output is correct |
3 |
Correct |
13 ms |
376 KB |
Output is correct |
4 |
Correct |
14 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
396 KB |
Output is correct |
2 |
Correct |
90 ms |
248 KB |
Output is correct |
3 |
Correct |
54 ms |
316 KB |
Output is correct |
4 |
Correct |
93 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
248 KB |
Output is correct |
2 |
Correct |
62 ms |
500 KB |
Output is correct |
3 |
Correct |
102 ms |
492 KB |
Output is correct |
4 |
Correct |
94 ms |
324 KB |
Output is correct |