結果

問題 No.1812 Uribo Road
ユーザー ああいいああいい
提出日時 2022-01-14 23:18:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 805 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 460,004 KB
最終ジャッジ日時 2024-04-30 17:16:50
合計ジャッジ時間 9,254 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,252 KB
testcase_01 AC 40 ms
53,500 KB
testcase_02 AC 41 ms
53,784 KB
testcase_03 AC 249 ms
79,008 KB
testcase_04 AC 39 ms
52,872 KB
testcase_05 AC 41 ms
54,216 KB
testcase_06 AC 40 ms
53,296 KB
testcase_07 AC 48 ms
60,240 KB
testcase_08 AC 366 ms
80,964 KB
testcase_09 AC 757 ms
87,536 KB
testcase_10 AC 307 ms
79,672 KB
testcase_11 AC 197 ms
78,324 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 #

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