답안 #59310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59310 2018-07-21T13:20:36 Z wilwxk Sailing Race (CEOI12_race) C++11
5 / 100
357 ms 4948 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=103;
vector<int> g[MAXN];
int dp[MAXN][MAXN][MAXN];
int n, k;

bool dentro(int ini, int fim, int val) {
    if(ini<=fim) return (ini<=val&&val<=fim);
    else {
        if(val==ini||val==fim) return 1;
        fim+=n; val+=n;
        return (ini<=val&&val<=fim);
    }
}

int fazdp(int cur, int ini, int fim) {
    if(dp[cur][ini][fim]!=-1) return dp[cur][ini][fim];
    if(ini==fim&&cur==ini) return 0; if(ini<1||fim<1) return 0;
    //printf("chama %d %d %d\n", cur, ini, fim);

    dp[cur][ini][fim]=0; int resp=0;

    for(auto viz : g[cur]) {
        if(!dentro(ini, fim, viz)) continue;

        int vini, vfim;
        if(dentro(cur+1, fim, viz)) {
            vini=cur+1;
            vfim=fim;
        }
        else {
            vini=ini;
            vfim=cur-1;
        }
        if(vini>n) vini%=n; if(vfim>n) vfim%=n;

        //printf("viz: %d %d %d // %d %d\n", ini, fim, viz, vini, vfim);
        resp=max(resp,  fazdp(viz, vini, vfim)+1 );

    }

    //printf("%d %d %d = %d\n", cur, ini, fim, resp);
    return dp[cur][ini][fim]=resp;
}

int main() {
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++) {
        while(1) {
            int a; scanf("%d", &a);
            if(a==0) break;
            g[i].push_back(a);
        }
    }

    memset(dp, -1, sizeof(dp)); int resp=0; int respp=1;

    //fazdp(6, 7, 5);
    for(int i=1; i<=n; i++) {
        if(fazdp(i, i+1, i-1)>resp) {
            resp=fazdp(i, i+1, i-1);
            respp=i;
        }
    }

    printf("%d\n%d\n", resp, respp);
}

Compilation message

race.cpp: In function 'int fazdp(int, int, int)':
race.cpp:20:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(ini==fim&&cur==ini) return 0; if(ini<1||fim<1) return 0;
     ^~
race.cpp:20:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     if(ini==fim&&cur==ini) return 0; if(ini<1||fim<1) return 0;
                                      ^~
race.cpp:37:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vini>n) vini%=n; if(vfim>n) vfim%=n;
         ^~
race.cpp:37:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(vini>n) vini%=n; if(vfim>n) vfim%=n;
                             ^~
race.cpp: In function 'int main()':
race.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
race.cpp:52:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int a; scanf("%d", &a);
                    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4600 KB Output is correct
2 Incorrect 6 ms 4712 KB Output isn't correct
3 Incorrect 5 ms 4712 KB Output isn't correct
4 Incorrect 8 ms 4712 KB Output isn't correct
5 Incorrect 10 ms 4712 KB Output isn't correct
6 Incorrect 9 ms 4712 KB Output isn't correct
7 Incorrect 42 ms 4712 KB Output isn't correct
8 Incorrect 9 ms 4748 KB Output isn't correct
9 Incorrect 45 ms 4820 KB Output isn't correct
10 Incorrect 357 ms 4908 KB Output isn't correct
11 Incorrect 113 ms 4948 KB Output isn't correct
12 Runtime error 3 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 4 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 6 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 6 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 4 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 4 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 5 ms 4948 KB Execution killed with signal 11 (could be triggered by violating memory limits)