답안 #1091410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091410 2024-09-20T19:31:49 Z AtinaR Sailing Race (CEOI12_race) C++14
40 / 100
400 ms 4948 KB
#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;
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:52:26: warning: 'poz' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |     cout<<res<<endl<<poz+1<<endl;
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 604 KB Output isn't correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Correct 1 ms 708 KB Output is correct
6 Incorrect 2 ms 856 KB Output isn't correct
7 Correct 3 ms 860 KB Output is correct
8 Incorrect 2 ms 1116 KB Output isn't correct
9 Correct 5 ms 1124 KB Output is correct
10 Correct 9 ms 1308 KB Output is correct
11 Correct 7 ms 1116 KB Output is correct
12 Incorrect 23 ms 1892 KB Output isn't correct
13 Incorrect 55 ms 2952 KB Output isn't correct
14 Correct 120 ms 3668 KB Output is correct
15 Incorrect 305 ms 4688 KB Output isn't correct
16 Incorrect 344 ms 4948 KB Output isn't correct
17 Incorrect 305 ms 4688 KB Output isn't correct
18 Correct 145 ms 4432 KB Output is correct
19 Incorrect 400 ms 4772 KB Output isn't correct
20 Incorrect 389 ms 4688 KB Output isn't correct