Submission #222255

# Submission time Handle Problem Language Result Execution time Memory
222255 2020-04-12T18:48:50 Z dolphingarlic Sailing Race (CEOI12_race) C++14
0 / 100
168 ms 2560 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

vector<int> graph[501];
int dp[501][501][2];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, t;
    cin >> n >> t;
    FOR(i, 0, n) {
        int v;
        cin >> v;
        while (v) {
            graph[i].push_back(v - 1);
            cin >> v;
        }
    }

    FOR(k, 0, n) {
        FOR(i, 0, n) {
            int j = (i + k) % n;
            for (int v : graph[i]) {
                if ((v > i && v <= i + k) || (v > i - n && v <= i + k - n)) {
                    dp[i][j][0] = max(dp[i][j][0], max(dp[v][j][0], dp[i][v][1]) + 1);
                }
            }
            for (int v : graph[(i + k) % n]) {
                if ((v >= i && v < i + k) || (v >= i - n && v < i + k - n)) {
                    dp[i][j][1] = max(dp[i][j][1], max(dp[v][j][0], dp[i][j][1]) + 1);
                }
            }
        }
    }

    if (t) {

    } else {
        int ans = 0, best = -1;
        FOR(k, 0, n + 1) FOR(i, 0, n) {
            if (dp[i][(i + k) % n][0] > ans) ans = dp[i][(i + k) % n][0], best = i;
            if (dp[i][(i + k) % n][1] > ans) ans = dp[i][(i + k) % n][1], best = (i + k) % n;
        }
        cout << ans << '\n' << best + 1 << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Incorrect 4 ms 384 KB Unexpected end of file - int32 expected
3 Incorrect 5 ms 512 KB Unexpected end of file - int32 expected
4 Incorrect 5 ms 512 KB Unexpected end of file - int32 expected
5 Incorrect 5 ms 512 KB Output isn't correct
6 Incorrect 5 ms 512 KB Unexpected end of file - int32 expected
7 Incorrect 6 ms 640 KB Output isn't correct
8 Incorrect 5 ms 640 KB Unexpected end of file - int32 expected
9 Incorrect 7 ms 768 KB Output isn't correct
10 Incorrect 12 ms 768 KB Output isn't correct
11 Incorrect 8 ms 768 KB Output isn't correct
12 Incorrect 14 ms 1152 KB Unexpected end of file - int32 expected
13 Incorrect 23 ms 1536 KB Unexpected end of file - int32 expected
14 Incorrect 38 ms 2048 KB Output isn't correct
15 Incorrect 104 ms 2432 KB Unexpected end of file - int32 expected
16 Incorrect 131 ms 2560 KB Unexpected end of file - int32 expected
17 Incorrect 106 ms 2432 KB Unexpected end of file - int32 expected
18 Incorrect 47 ms 2424 KB Output isn't correct
19 Incorrect 155 ms 2560 KB Unexpected end of file - int32 expected
20 Incorrect 168 ms 2560 KB Unexpected end of file - int32 expected