結果

問題 No.1812 Uribo Road
ユーザー ああいいああいい
提出日時 2022-01-14 23:19:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 836 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 87,564 KB
最終ジャッジ日時 2024-04-30 17:20:09
合計ジャッジ時間 9,097 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,888 KB
testcase_01 AC 40 ms
54,248 KB
testcase_02 AC 39 ms
53,692 KB
testcase_03 AC 241 ms
78,888 KB
testcase_04 AC 37 ms
53,228 KB
testcase_05 AC 39 ms
53,812 KB
testcase_06 AC 40 ms
53,092 KB
testcase_07 AC 46 ms
61,324 KB
testcase_08 AC 354 ms
80,484 KB
testcase_09 AC 758 ms
87,564 KB
testcase_10 AC 302 ms
78,952 KB
testcase_11 AC 188 ms
78,412 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
r = sys.stdin

N,M,K = map(int,r.readline().split())
R = list(map(int,r.readline().split()))
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))
    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])
0