結果
問題 | No.845 最長の切符 |
ユーザー | yuki2006 |
提出日時 | 2019-06-28 00:21:03 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 712 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 10,936 KB |
実行使用メモリ | 14,972 KB |
最終ジャッジ日時 | 2023-09-14 21:09:24 |
合計ジャッジ時間 | 7,005 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
7,808 KB |
testcase_01 | AC | 17 ms
7,816 KB |
testcase_02 | AC | 19 ms
8,208 KB |
testcase_03 | AC | 17 ms
7,860 KB |
testcase_04 | AC | 15 ms
7,820 KB |
testcase_05 | AC | 15 ms
7,776 KB |
testcase_06 | AC | 15 ms
7,808 KB |
testcase_07 | AC | 15 ms
7,872 KB |
testcase_08 | AC | 19 ms
8,376 KB |
testcase_09 | AC | 16 ms
7,820 KB |
testcase_10 | AC | 69 ms
8,996 KB |
testcase_11 | AC | 21 ms
8,248 KB |
testcase_12 | AC | 31 ms
8,356 KB |
testcase_13 | AC | 18 ms
8,412 KB |
testcase_14 | AC | 23 ms
8,216 KB |
testcase_15 | AC | 882 ms
14,972 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
N, M = map(int, input().split()) edge = [[-1 for i in range(N + 1)] for j in range(N)] for i in range(M): a, b, c = map(int, input().split()) a -= 1 b -= 1 edge[a][b] = edge[b][a] = max(edge[b][a], c) dp = [[-1 for i in range(N)] for j in range(1 << N)] for i in range(N): dp[1 << i][i] = 0 mx = 0 for bit in range(1 << N): for i in range(N): if dp[bit][i] < 0: continue flag = False for j in range(N): if bit & (1 << j) == 0 and edge[i][j] >= 0: flag = True dp[bit | (1 << j)][j] = max(dp[bit | (1 << j)][j], dp[bit][i] + edge[i][j]) if not flag: mx = max(mx, dp[bit][i]) print(mx)