結果
| 問題 | No.788 トラックの移動 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-04 09:39:10 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 811 bytes |
| 記録 | |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 100,764 KB |
| 最終ジャッジ日時 | 2024-06-30 14:51:55 |
| 合計ジャッジ時間 | 6,793 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 13 |
ソースコード
from collections import defaultdict
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
N, M, L = map(int, input().split())
L -= 1 # 0-indexed
T = np.array(list(map(int, input().split())))
nonzero = np.nonzero(T)[0]
d = defaultdict(lambda: 10000)
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
d[(a, b)] = min(d[(a, b)], c)
frm, to, length = [], [], []
for (a, b), c in d.items():
frm.append(a)
to.append(b)
length.append(c)
matr = csr_matrix((length, (frm, to)), shape=(N, N))
way = dijkstra(matr, directed=False).astype(int)
ans = np.inf
for target in range(N):
tmp = np.sum(way[target] * 2 * T)
first = np.max(way[target][nonzero] - way[L][nonzero])
tmp -= first
ans = min(ans, tmp)
print(ans)