結果

問題 No.1812 Uribo Road
コンテスト
ユーザー ytft
提出日時 2022-02-13 16:55:38
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 503 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 402 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 1,015,588 KB
最終ジャッジ日時 2026-03-18 15:28:49
合計ジャッジ時間 125,667 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 MLE * 3
other AC * 8 TLE * 11 MLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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