結果
問題 |
No.788 トラックの移動
|
ユーザー |
![]() |
提出日時 | 2021-02-12 01:29:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 210,868 KB |
最終ジャッジ日時 | 2024-07-18 12:00:05 |
合計ジャッジ時間 | 22,515 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 3 TLE * 2 |
ソースコード
import sys def MI(): return map(int, sys.stdin.buffer.readline().split()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] inf = 10**16 import numpy as np from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix n, m, l = MI() l -= 1 tt = np.array(LI(), dtype="i8") if np.sum(tt == 0) >= n-1: print(0) exit() e = np.array(LLI(m), dtype="i8").T g = csr_matrix((e[2], e[:2]-1), (n, n)) dd = dijkstra(g, directed=False).astype("i8") iscar = tt > 0 ans = inf for g in range(n): cur = np.sum(tt*dd[g])*2+np.min(dd[l][iscar]-dd[g][iscar]) if cur < ans: ans = cur print(ans)