# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287651 |
2020-08-31T21:55:32 Z |
luciocf |
popa (BOI18_popa) |
C++14 |
|
751 ms |
508 KB |
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
const int maxn = 1e3+10;
int n;
int L[maxn], R[maxn];
int a[maxn], b[maxn];
int root;
bool mark[maxn];
int f(int l, int r)
{
if (l > r) return -1;
for (int i = 0; i < n; i++)
{
if (!mark[i] && a[i] <= l && b[i] >= r)
{
if (l == 0 && r == n-1) root = i;
mark[i] = 1;
L[i] = f(l, i-1);
R[i] = f(i+1, r);
return i;
}
}
}
void get(int i)
{
int ini = 0, fim = i-1;
a[i] = i;
while (ini <= fim)
{
int mid = (ini+fim)>>1;
if (query(mid, i, i, i)) a[i] = mid, fim = mid-1;
else ini = mid+1;
}
ini = i+1, fim = n-1;
b[i] = i;
while (ini <= fim)
{
int mid = (ini+fim)>>1;
if (query(i, mid, i, i)) b[i] = mid, ini = mid+1;
else fim = mid-1;
}
}
int solve(int N, int *Left, int *Right)
{
memset(mark, 0, sizeof mark);
n = N;
for (int i = 0; i < n; i++)
get(i);
f(0, n-1);
for (int i = 0; i < n; i++)
Left[i] = L[i], Right[i] = R[i];
return root;
}
Compilation message
popa.cpp: In function 'int f(int, int)':
popa.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
34 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
384 KB |
Output is correct |
2 |
Correct |
47 ms |
504 KB |
Output is correct |
3 |
Correct |
48 ms |
380 KB |
Output is correct |
4 |
Correct |
41 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
647 ms |
508 KB |
Output is correct |
2 |
Correct |
748 ms |
504 KB |
Output is correct |
3 |
Correct |
491 ms |
384 KB |
Output is correct |
4 |
Correct |
751 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
384 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |