Submission #1090321

# Submission time Handle Problem Language Result Execution time Memory
1090321 2024-09-18T08:41:43 Z vjudge1 Sailing Race (CEOI12_race) C++17
0 / 100
710 ms 6488 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define ar array

//const int INF = 1e17;
const int N = 600;
const int Q = 105;
const int MOD = 1e9 + 7;
const int LOG = 60;

int dp[N][N][2];
int n;
bool g[N][N];

int f(int l,int r,bool d){
    if(dp[l][r][d] != -1)return dp[l][r][d];
    int ans = 0;

    for(int i = (l + 1) % n;i != r;i = (i + 1) % n){
        int prv = d ? l : r; 
        if(g[prv][i]){
            ans = max(ans, f(l, i, 0) + 1);
            ans = max(ans, f(i,r,1) + 1);
        }
    }

    return dp[l][r][d] = ans;
}

signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin>>n;
    int garb;
    cin>>garb;
    for(int i = 0;i < n;i++){
        int x;
        cin>>x;
        while(x){
            g[i][x - 1] = 1;
            cin>>x;
        }
    }
    int ans = 0;
    int mi = - 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(!g[i][j])continue;
            int res = f(i, j, 0) + 1;
            if(res > ans){
                ans = res;
                mi = i;
            }
            res = f(j, i, 1) + 1;
            if(res > ans){
                ans = res;
                mi = i;
            }
        }
    }
    cout<<ans<<" "<<mi<<'\n';
}  


//! MI SE SPIEEEEE!
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5976 KB Output isn't correct
2 Incorrect 3 ms 5980 KB Output isn't correct
3 Incorrect 4 ms 5876 KB Output isn't correct
4 Incorrect 4 ms 5980 KB Output isn't correct
5 Incorrect 3 ms 5980 KB Output isn't correct
6 Incorrect 3 ms 5980 KB Output isn't correct
7 Incorrect 5 ms 5980 KB Output isn't correct
8 Incorrect 4 ms 5980 KB Output isn't correct
9 Incorrect 9 ms 5980 KB Output isn't correct
10 Incorrect 14 ms 5980 KB Output isn't correct
11 Incorrect 12 ms 5980 KB Output isn't correct
12 Incorrect 41 ms 6204 KB Output isn't correct
13 Incorrect 114 ms 6248 KB Output isn't correct
14 Incorrect 259 ms 6232 KB Output isn't correct
15 Incorrect 659 ms 6488 KB Output isn't correct
16 Incorrect 710 ms 6364 KB Output isn't correct
17 Incorrect 657 ms 6236 KB Output isn't correct
18 Incorrect 450 ms 6232 KB Output isn't correct
19 Incorrect 698 ms 6232 KB Output isn't correct
20 Incorrect 704 ms 6232 KB Output isn't correct