Submission #59325

# Submission time Handle Problem Language Result Execution time Memory
59325 2018-07-21T14:13:32 Z wilwxk Sailing Race (CEOI12_race) C++11
0 / 100
577 ms 4944 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;
            if(ini==cur) vini++;
            if(fim==cur) vfim--;
            vfim=cur;
        }
        else {
            vini=cur;
            if(ini==cur) vini++;
            if(fim==cur) vfim--;
            vfim=fim;
        }
        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:38:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vini==0) vini=n; if(vfim==0) vfim=n;
         ^~
race.cpp:38: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:39:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(vini>n) vini%=n; if(vfim>n) vfim%=n;
         ^~
race.cpp:39: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);
                    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4600 KB Output isn't correct
2 Incorrect 7 ms 4600 KB Output isn't correct
3 Incorrect 6 ms 4656 KB Output isn't correct
4 Incorrect 8 ms 4832 KB Output isn't correct
5 Incorrect 11 ms 4832 KB Output isn't correct
6 Incorrect 18 ms 4832 KB Output isn't correct
7 Incorrect 81 ms 4872 KB Output isn't correct
8 Incorrect 13 ms 4872 KB Output isn't correct
9 Incorrect 83 ms 4944 KB Output isn't correct
10 Incorrect 577 ms 4944 KB Output isn't correct
11 Incorrect 136 ms 4944 KB Output isn't correct
12 Runtime error 5 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 4 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 5 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 6 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 5 ms 4944 KB Execution killed with signal 11 (could be triggered by violating memory limits)