結果
| 問題 | No.788 トラックの移動 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-04 09:49:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 838 bytes |
| 記録 | |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 177,792 KB |
| 最終ジャッジ日時 | 2024-06-30 15:00:17 |
| 合計ジャッジ時間 | 6,503 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 2 TLE * 3 |
ソースコード
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())), dtype=np.int64)
nonzero = np.nonzero(T)[0]
d = defaultdict(lambda: 2 * 10 ** 6)
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(np.int64)
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)