結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,088 KB
testcase_01 AC 15 ms
8,108 KB
testcase_02 AC 17 ms
8,088 KB
testcase_03 AC 170 ms
10,372 KB
testcase_04 AC 16 ms
8,104 KB
testcase_05 AC 16 ms
8,072 KB
testcase_06 AC 17 ms
8,100 KB
testcase_07 AC 17 ms
8,112 KB
testcase_08 AC 262 ms
11,996 KB
testcase_09 AC 582 ms
15,616 KB
testcase_10 AC 215 ms
11,704 KB
testcase_11 AC 98 ms
9,808 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