結果

問題 No.788 トラックの移動
ユーザー maspymaspy
提出日時 2020-03-17 10:49:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 682 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 243,592 KB
最終ジャッジ日時 2024-11-30 07:02:35
合計ジャッジ時間 25,913 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 3 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

# %%
N, M, L = map(int, readline().split())
T = np.array(readline().split(), np.int64)
ABC = np.array(read().split(), np.int64)
A = ABC[::3]
B = ABC[1::3]
C = ABC[2::3]

# %%
graph = csr_matrix((C, (A - 1, B - 1)), (N, N))
dist = dijkstra(graph, directed=False)

# %%
dist = (dist + .5).astype(np.int64)
cost = (dist * T[None, :]).sum(axis=1) * 2
diff = dist[L - 1][None, :] - dist * (T > 0)
cost = cost[:, None] + diff
print(cost.min())
0