#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
int solve (int l, int r, int *Left, int *Right)
{
if (l > r) return -1;
if (l == r)
return l;
if (r == l + 1)
{
if (query (l, l, l, r))
{
Right[l] = r;
return l;
}
Left[r] = l;
return r;
}
int ras = (l + r) / 2;
for (int i=1; l + i - 1 <= r - i + 1; i++)
{
if (query (l, l + i - 1, l, r))
{
ras = l + i - 1;
break;
}
if (query (r - i + 1, r, l, r))
{
ras = r - i + 1;
break;
}
}
Left[ras] = solve (l, ras - 1, Left, Right);
Right[ras] = solve (ras + 1, r, Left, Right);
return ras;
}
int solve (int nn, int* Left, int* Right)
{
int N = nn;
for (int i=0; i<N; i++)
Left[i] = Right[i] = -1;
int root = solve (0, N - 1, Left, Right);
return root;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
376 KB |
Output is correct |
2 |
Correct |
18 ms |
376 KB |
Output is correct |
3 |
Correct |
13 ms |
376 KB |
Output is correct |
4 |
Correct |
16 ms |
548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
217 ms |
628 KB |
Output is correct |
2 |
Correct |
112 ms |
748 KB |
Output is correct |
3 |
Correct |
173 ms |
748 KB |
Output is correct |
4 |
Correct |
239 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
748 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |