#include "popa.h"
#include <iostream>
using namespace std;
const int nmax=1005;
int i,st[nmax],dr[nmax],root,p,n,len,j;
int dp[nmax][nmax];
int l[nmax],r[nmax];
int par[nmax][nmax];
void deco(int st,int dr)
{
int x=par[dr-st+1][st];
if(st==dr) x=st;
if(x>st)
{
l[x]=par[x-st][st];
deco(st,x-1);
}
else
l[x]=-1;
if(x<dr)
{
r[x]=par[dr-x][x+1];
deco(x+1,dr);
}
else r[x]=-1;
}
int solve(int N, int* Left, int* Right)
{
for(i=1;i<N;i++)
{
st[i]=i;
for(p=9;p>=0;p--)
if(st[i]-(1<<p)>=0&&query(st[i]-(1<<p),i,i,i))
st[i]-=(1<<p);
}
dr[N-1]=N-1;
for(i=N-2;i>=0;i--)
{
dr[i]=i;
for(p=9;p>=0;p--)
if(dr[i]+(1<<p)<N&&query(i,dr[i]+(1<<p),i,i))
dr[i]+=(1<<p);
}
for(len=1;len<=n;len++)
for(i=0;i<n-i;i++)
dp[len][i]=0;
n=N;
for(i=0;i<n;i++)
dp[1][i]=dp[0][i]=1,par[1][i]=i;
for(len=2;len<=n;len++)
{
for(i=0;i<=n-len;i++)
{
for(j=i;j<i+len&&(!dp[len][i]);j++)
{
if(dp[j-i][i]&&dp[len-(j-i+1)][j+1]&&st[j]<=i&&dr[j]>=i+len-1)
dp[len][i]=1,par[len][i]=j;
}
}
}
deco(0,n-1);
for(i=0;i<n;i++)
Left[i]=l[i],Right[i]=r[i];
return par[n][0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
1016 KB |
not a valid solution |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
8328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
8328 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |