結果

問題 No.1812 Uribo Road
ユーザー vwxyzvwxyz
提出日時 2023-02-24 05:54:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 767 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 379,996 KB
最終ジャッジ日時 2023-10-01 03:41:31
合計ジャッジ時間 8,379 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,028 KB
testcase_01 AC 16 ms
8,040 KB
testcase_02 AC 17 ms
8,128 KB
testcase_03 AC 171 ms
10,408 KB
testcase_04 AC 15 ms
8,040 KB
testcase_05 AC 15 ms
8,144 KB
testcase_06 AC 16 ms
8,132 KB
testcase_07 AC 16 ms
8,000 KB
testcase_08 AC 259 ms
11,972 KB
testcase_09 AC 552 ms
15,608 KB
testcase_10 AC 200 ms
11,784 KB
testcase_11 AC 97 ms
9,772 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
readline=sys.stdin.readline
import heapq

N,M,K=map(int,readline().split())
R=list(map(int,readline().split()))
graph=[[] for x in range(N)]
idx=[-1]*M
for k in range(K):
    R[k]-=1
    idx[R[k]]=k
for m in range(M):
    A,B,C=map(int,readline().split())
    A-=1;B-=1
    graph[A].append((B,C,idx[m]))
    graph[B].append((A,C,idx[m]))
inf=1<<30
dist=[[inf]*N for bit in range(1<<K)]
dist[0][0]=0
queue=[]
queue=[(0,0,0)]
while queue:
    dx,bitx,x=heapq.heappop(queue)
    if dist[bitx][x]<dx:
        continue
    for y,dy,i in graph[x]:
        bity=bitx
        if i!=-1:
            bity|=1<<i
        if dist[bity][y]>dx+dy:
            dist[bity][y]=dx+dy
            heapq.heappush(queue,(dist[bity][y],bity,y))
ans=dist[(1<<K)-1][N-1]
print(ans)
0