結果
| 問題 |
No.3158 Collect Stamps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-18 11:33:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 604 bytes |
| コンパイル時間 | 402 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 89,216 KB |
| 最終ジャッジ日時 | 2025-05-18 11:33:52 |
| 合計ジャッジ時間 | 4,385 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 32 |
ソースコード
from itertools import permutations 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)