# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
261555 | 2020-08-11T21:09:19 Z | tincamatei | Sailing Race (CEOI12_race) | C++14 | 1074 ms | 2680 KB |
#include <bits/stdc++.h> const int MAX_N = 500; bool graph[MAX_N][MAX_N]; int asc[MAX_N][MAX_N], desc[MAX_N][MAX_N]; int main() { int N, K; scanf("%d%d", &N, &K); for(int i = 0; i < N; ++i) { int t; scanf("%d", &t); while(t != 0) { graph[i][t - 1] = true; scanf("%d", &t); } } for(int len = 2; len <= N; ++len) { for(int i = 0; i < N; ++i) { int j = (i + len - 1) % N, k = i; do { k = (k + 1) % N; if(graph[i][k]) asc[i][j] = std::max(asc[i][j], 1 + std::max(asc[k][j], desc[k][(i + 1) % N])); } while(k != j); j = (i + N - len + 1) % N; k = i; do { k = (k + N - 1) % N; if(graph[i][k]) desc[i][j] = std::max(desc[i][j], 1 + std::max(desc[k][j], asc[k][(i - 1 + N) % N])); } while(k != j); } } int best_len = 0, start_path = 0; for(int i = 0; i < N; ++i) { int ii = ((i + N - 1) % N); if(asc[i][ii] > best_len) { best_len = asc[i][ii]; start_path = i; } ii = (i + 1) % N; if(desc[i][ii] > best_len) { best_len = desc[i][ii]; start_path = i; } } printf("%d\n%d", best_len, start_path + 1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Incorrect | 1 ms | 384 KB | Output isn't correct |
4 | Incorrect | 1 ms | 512 KB | Output isn't correct |
5 | Correct | 2 ms | 512 KB | Output is correct |
6 | Incorrect | 3 ms | 640 KB | Output isn't correct |
7 | Correct | 5 ms | 640 KB | Output is correct |
8 | Incorrect | 5 ms | 640 KB | Output isn't correct |
9 | Correct | 9 ms | 768 KB | Output is correct |
10 | Correct | 12 ms | 768 KB | Output is correct |
11 | Correct | 13 ms | 768 KB | Output is correct |
12 | Incorrect | 66 ms | 1152 KB | Output isn't correct |
13 | Incorrect | 188 ms | 1724 KB | Output isn't correct |
14 | Correct | 419 ms | 2168 KB | Output is correct |
15 | Incorrect | 926 ms | 2680 KB | Output isn't correct |
16 | Incorrect | 988 ms | 2560 KB | Output isn't correct |
17 | Incorrect | 940 ms | 2680 KB | Output isn't correct |
18 | Correct | 774 ms | 2560 KB | Output is correct |
19 | Incorrect | 1048 ms | 2560 KB | Output isn't correct |
20 | Incorrect | 1074 ms | 2680 KB | Output isn't correct |