답안 #59333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59333 2018-07-21T14:44:31 Z wilwxk Sailing Race (CEOI12_race) C++11
5 / 100
638 ms 4964 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;
        return !(fim<=val&&val<=ini);
    }
}

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

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

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

        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;

    // resp=fazdp(6, 7, 6);
    for(int i=1; i<=n; i++) {
        if(fazdp(i, i==n ? 1 : i+1, i)>resp) {
            resp=fazdp(i, i==n ? 1 : i+1, i);
            respp=i;
        }
        //printf("asd %d: %d\n", i, fazdp(i, i+1, i));
    }

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

Compilation message

race.cpp: In function 'int fazdp(int, int, int)':
race.cpp:34:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vini==0) vini=n; if(vfim==0) vfim=n;
         ^~
race.cpp:34:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(vini==0) vini=n; if(vfim==0) vfim=n;
                             ^~
race.cpp:35:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vini>n) vini%=n; if(vfim>n) vfim%=n;
         ^~
race.cpp:35: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:45: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:48: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 Incorrect 6 ms 4676 KB Output isn't correct
2 Incorrect 6 ms 4676 KB Output isn't correct
3 Incorrect 6 ms 4676 KB Output isn't correct
4 Incorrect 7 ms 4840 KB Output isn't correct
5 Incorrect 16 ms 4840 KB Output isn't correct
6 Incorrect 14 ms 4896 KB Output isn't correct
7 Incorrect 76 ms 4896 KB Output isn't correct
8 Incorrect 17 ms 4896 KB Output isn't correct
9 Incorrect 117 ms 4896 KB Output isn't correct
10 Correct 638 ms 4924 KB Output is correct
11 Incorrect 272 ms 4964 KB Output isn't correct
12 Runtime error 4 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 5 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 5 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 3 ms 4964 KB Execution killed with signal 11 (could be triggered by violating memory limits)