Submission #39373

# Submission time Handle Problem Language Result Execution time Memory
39373 2018-01-13T08:29:33 Z aome Sailing Race (CEOI12_race) C++14
0 / 100
443 ms 5168 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 505;

int n, subtask;
int res;
int a[N][N];
int f[2][N][N];

int nxt(int i) { return i == (n - 1) ? 0 : (i + 1); }
int prv(int i) { return i == 0 ? (n - 1) : (i - 1); }

int calF(int t, int l, int r) {
    int &F = f[t][l][r];
    if (F != -1) return F;
    F = 0;
    if (t == 0) {
        for (int i = l; i != r; i = nxt(i)) {
            if (!a[l][i]) continue;
            F = max(F, max(calF(1, l, i), calF(0, i, r)) + 1);
        }
    }
    else {
        for (int i = nxt(l); i != r; i = nxt(i)) {
            if (!a[r][i]) continue;
            F = max(F, max(calF(0, i, r), calF(1, l, i)) + 1);
        }
    }
    res = max(res, F); return F;
}

int main() {
    // subtask 0
    ios::sync_with_stdio(false);
    cin >> n >> subtask;
    assert(subtask == 0);
    for (int i = 0; i < n; ++i) {
        int x; 
        while (cin >> x && x) a[i][x - 1] = 1;
    }
    memset(f, -1, sizeof f);
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                calF(i, j, k);
            }
        }
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5164 KB Unexpected end of file - int32 expected
2 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
3 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
4 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
5 Incorrect 0 ms 5164 KB Unexpected end of file - int32 expected
6 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
7 Incorrect 6 ms 5164 KB Unexpected end of file - int32 expected
8 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
9 Incorrect 13 ms 5164 KB Unexpected end of file - int32 expected
10 Incorrect 13 ms 5164 KB Unexpected end of file - int32 expected
11 Incorrect 13 ms 5164 KB Unexpected end of file - int32 expected
12 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
13 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
14 Incorrect 256 ms 5164 KB Unexpected end of file - int32 expected
15 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
16 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
17 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
18 Incorrect 443 ms 5164 KB Unexpected end of file - int32 expected
19 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)
20 Runtime error 0 ms 5168 KB Execution killed because of forbidden syscall gettid (186)