#include <cstdio>
#include "popa.h"
int solve (int N , int *Left , int *Right){ /// return root
int i,root,u;
int st[1010];
for (i=0;i<N;i++){
Left[i] = Right[i] = -1; /// reset all
}
/// primul e clar frunza
u = 1;
st[1] = 0;
root = 0;
for (i=1;i<N;i++){
while (u && query (st[u],i,i,i)){
u--;
}
if (u){ /// nu dev root
Left[i] = Right[st[u]];
Right[st[u]] = i;
}
else {
Left[i] = root;
root = i;
}
st[++u] = i;
}
return root;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
248 KB |
Output is correct |
2 |
Correct |
19 ms |
376 KB |
Output is correct |
3 |
Correct |
13 ms |
376 KB |
Output is correct |
4 |
Correct |
24 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
376 KB |
Output is correct |
2 |
Correct |
98 ms |
312 KB |
Output is correct |
3 |
Correct |
64 ms |
376 KB |
Output is correct |
4 |
Correct |
84 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
436 KB |
Output is correct |
2 |
Correct |
53 ms |
316 KB |
Output is correct |
3 |
Correct |
83 ms |
312 KB |
Output is correct |
4 |
Correct |
101 ms |
312 KB |
Output is correct |