結果
| 問題 |
No.3158 Collect Stamps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-18 11:34:39 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 567 bytes |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 18,340 KB |
| 最終ジャッジ日時 | 2025-05-18 11:34:44 |
| 合計ジャッジ時間 | 4,355 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 32 |
ソースコード
N, M, K = map(int, input().split()) A = set(map(lambda x: int(x) - 1, input().split())) T = [list(map(int, input().split())) for _ in range(N)] ans = 10 ** 18 # dfs で順列全探索 def generate_permutations(determined, left, m): if m == 0: yield determined for add in left: left_copy = [x for x in left if x != add] for p in generate_permutations(determined + [add], left_copy, m-1): yield p for p in generate_permutations([], list(range(N)), M): if p[-1] not in A: continue ans = min(ans, sum(T[p[i]][p[i+1]] for i in range(M-1))) print(ans)