Submission #285163

# Submission time Handle Problem Language Result Execution time Memory
285163 2020-08-28T11:22:12 Z CaroLinda Sailing Race (CEOI12_race) C++14
0 / 100
68 ms 2552 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define mkt make_tuple
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define ff first
#define ss second
#define eb push_back
#define ll long long
#define mk make_pair
#define pii pair<int,int>
#define debug printf
#define all(x) x.begin(),x.end()

const int MAXN = 510 ;

using namespace std ;

int N , K ;
int t[2] = {-1,1} ;
int dp[MAXN][MAXN][2] ;
vector<int> adj[MAXN] ;

bool isInside(int x, int L , int R , int type )
{

    if(type == -1) swap(L,R) , type = 1 ;

    if( L >= R ) return (L <= x || x <= R ) ;
    return L <= x && x <= R ;

}

void caso0()
{
    int ans = 0  ;

    for(int diff = 1 ; diff < N ; diff++ )
        for(int i = 0 ; i < N ; i++ )
            for(int j = 0 ; j < 2 ; j++ )
            {
                int R = ( i + diff * t[j] + N ) % N ;
                int &ptr = dp[i][R][j] ;
                ptr = 0 ;

                //cout << i << " " << R << endl ;

                for(int viz : adj[i] )
                {
                    if(!isInside(viz, i , R, t[j] ) ) continue ;

                    //cout << "A ponta " << viz << " ta dentro" << endl ;

                    ptr = max(ptr, 1 + dp[viz][R][j] ) ;
                    if( viz != i + t[j] ) ptr = max(ptr, 1 + dp[viz][ i+t[j] ][ !t[j] ] ) ;

                }

                ans = max(ans, ptr) ;
            }

   /* for(int i = 0 ; i < N ; i++)
    {
        debug("dp %d:\n" , i )  ;
        for(int j = 0 ; j < N ; j++ ) debug("(%d,%d) e (%d, %d)\n", j, dp[i][j][0] ,j, dp[i][j][1] ) ;
        debug("\n") ;
    } */

    printf("%d\n" , ans ) ;

    exit(0) ;
}

int main()
{
    scanf("%d%d", &N , &K ) ;
    for(int i = 0 , x ; i < N ; i++ )
        while( scanf("%d", &x) && x != 0 ) adj[i].push_back(x-1) ;

    if(K == 0) caso0() ;
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:76:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   76 |     scanf("%d%d", &N , &K ) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 384 KB Unexpected end of file - int32 expected
3 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
4 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
5 Incorrect 1 ms 512 KB Output isn't correct
6 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
7 Incorrect 3 ms 640 KB Output isn't correct
8 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
9 Incorrect 4 ms 768 KB Output isn't correct
10 Incorrect 9 ms 768 KB Output isn't correct
11 Incorrect 5 ms 768 KB Output isn't correct
12 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
14 Incorrect 50 ms 2048 KB Output isn't correct
15 Incorrect 5 ms 512 KB Unexpected end of file - int32 expected
16 Incorrect 6 ms 768 KB Unexpected end of file - int32 expected
17 Incorrect 5 ms 640 KB Unexpected end of file - int32 expected
18 Incorrect 68 ms 2552 KB Output isn't correct
19 Incorrect 7 ms 768 KB Unexpected end of file - int32 expected
20 Incorrect 8 ms 768 KB Unexpected end of file - int32 expected