# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1091410 | AtinaR | Sailing Race (CEOI12_race) | C++14 | 400 ms | 4948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,k;
const int MAX=501;
bool mat[MAX][MAX];
int vis[MAX][MAX][2];
int dp[MAX][MAX][2];
int f(int a, int b, int dir)
{
bool t=(dir==a);
if(vis[a][b][t])return dp[a][b][t];
int res=0;
for(int i=a+1; i!=b; i++)
{
if(i==n)i=0;
if(i==b)break;
if(mat[dir][i])
{
res=max(res,f(a,i,i)+1);
res=max(res,f(i,b,i)+1);
}
}
vis[a][b][t]=true;
dp[a][b][t]=res;
return res;
}
int main()
{
cin>>n>>k;
for(int i=0; i<n; i++)
{
int x;
while(cin>>x)
{
if(x==0)break;
x--;
mat[i][x]=true;
}
}
int poz,res=0;
for(int i=0; i<n; i++)
{
int tmp=f(i,i,i);
if(tmp>res)
{
res=tmp;
poz=i;
}
}
cout<<res<<endl<<poz+1<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |