結果
問題 | No.1812 Uribo Road |
ユーザー | vwxyz |
提出日時 | 2023-02-24 05:54:42 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 1,095 ms |
コンパイル使用メモリ | 87,072 KB |
実行使用メモリ | 457,944 KB |
最終ジャッジ日時 | 2023-10-01 03:41:00 |
合計ジャッジ時間 | 9,825 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
71,448 KB |
testcase_01 | AC | 78 ms
71,388 KB |
testcase_02 | AC | 77 ms
71,308 KB |
testcase_03 | AC | 262 ms
81,116 KB |
testcase_04 | AC | 74 ms
71,424 KB |
testcase_05 | AC | 75 ms
71,308 KB |
testcase_06 | AC | 76 ms
71,164 KB |
testcase_07 | AC | 81 ms
75,680 KB |
testcase_08 | AC | 428 ms
83,024 KB |
testcase_09 | AC | 659 ms
88,736 KB |
testcase_10 | AC | 336 ms
80,548 KB |
testcase_11 | AC | 244 ms
80,164 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 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)