結果

問題 No.1812 Uribo Road
ユーザー ytft
提出日時 2022-02-13 16:55:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 503 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 609,868 KB
最終ジャッジ日時 2024-06-29 05:42:46
合計ジャッジ時間 21,867 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8 MLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path
N,M,K=map(int,input().split())
R=list(map(int,input().split()))
mask=[0 for i in range(M)]
for i in range(K):
	mask[R[i]-1]=pow(2,i)
weight=[]
begin=[]
end=[]
for i in range(M):
	A,B,C=map(int,input().split())
	for j in range(pow(2,K)):
		begin+=[A-1+j*N,B-1+j*N]
		end+=[B-1+(j|mask[i])*N,A-1+(j|mask[i])*N]
		weight+=[C,C]
graph=csr_matrix((weight,(begin,end)))
print(int(shortest_path(graph,indices=0)[N*pow(2,K)-1]))
0