# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287663 |
2020-08-31T22:04:43 Z |
luciocf |
popa (BOI18_popa) |
C++14 |
|
7 ms |
520 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)
{
a[i] = i, b[i] = i;
stack<int> stk;
for (int i = 0; i < n; i++)
{
while (stk.size() && !query(stk.top(), i, stk.top(), stk.top()))
stk.pop();
if (stk.size()) a[i] = stk.top()+1;
else a[i] = 0;
}
while (stk.size()) stk.pop();
for (int i = n-1; i >= 0; i--)
{
while (stk.size() && !query(i, stk.top(), stk.top(), stk.top()))
stk.pop();
if (stk.size()) a[i] = stk.top()-1;
else a[i] = n-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 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
520 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |