#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 = r, p = l, u = r - 1, mij;
while (p <= u)
{
mij = (p + u) >> 1;
if (query (l, mij, l, r)) ras = mij, u = mij - 1;
else p = mij + 1;
}
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 |
20 ms |
420 KB |
Output is correct |
2 |
Correct |
26 ms |
420 KB |
Output is correct |
3 |
Correct |
13 ms |
420 KB |
Output is correct |
4 |
Correct |
32 ms |
488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
240 ms |
740 KB |
Output is correct |
2 |
Correct |
336 ms |
740 KB |
Output is correct |
3 |
Correct |
67 ms |
740 KB |
Output is correct |
4 |
Correct |
216 ms |
740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
740 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |