結果
問題 | No.1812 Uribo Road |
ユーザー | ああいい |
提出日時 | 2022-01-14 23:21:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 884 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 459,800 KB |
最終ジャッジ日時 | 2024-04-30 17:23:37 |
合計ジャッジ時間 | 8,614 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
53,288 KB |
testcase_01 | AC | 33 ms
53,040 KB |
testcase_02 | AC | 36 ms
54,276 KB |
testcase_03 | AC | 206 ms
79,032 KB |
testcase_04 | AC | 33 ms
52,896 KB |
testcase_05 | AC | 33 ms
52,992 KB |
testcase_06 | AC | 34 ms
53,624 KB |
testcase_07 | AC | 44 ms
59,964 KB |
testcase_08 | AC | 292 ms
80,592 KB |
testcase_09 | AC | 600 ms
87,264 KB |
testcase_10 | AC | 251 ms
78,548 KB |
testcase_11 | AC | 158 ms
77,652 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
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 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
import sys r = sys.stdin N,M,K = map(int,r.readline().split()) R = list(map(int,r.readline().split())) Rset = set(R) G = [[] for _ in range(N+1)] #D = {v:i for i,v in enumerate(sorted(set(R)))} edge = dict() for i in range(M): a,b,c = map(int,r.readline().split()) G[a].append((b,c)) G[b].append((a,c)) if i + 1 not in Rset:continue for j in range(K): if R[j] == i + 1: edge[(a,b)] = j edge[(b,a)] = j C = 10 ** 15 dp = [[C] * (1<<K) for _ in range(N+1)] dp[0][0] = 0 import heapq q = [] heapq.heapify(q) heapq.heappush(q,(0,1,0)) while q: d,now,S = heapq.heappop(q) if d > dp[now][S]:continue for v,c in G[now]: if (now,v) in edge: T = S | (1 << edge[(now,v)]) else:T = S if dp[v][T] > d + c: dp[v][T] = d+c heapq.heappush(q,(d+c,v,T)) print(dp[N][(1<<K)-1])