結果

問題 No.1065 電柱 / Pole (Easy)
コンテスト
ユーザー H3PO4
提出日時 2020-05-29 21:42:52
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 652 ms
コンパイル使用メモリ 20,952 KB
実行使用メモリ 91,056 KB
最終ジャッジ日時 2026-05-06 05:21:27
合計ジャッジ時間 8,316 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1
other AC * 1 TLE * 3 -- * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1
N, M = map(int, input().split())
X, Y = map(int1, input().split())

P = [tuple(map(int, input().split())) for _ in range(N)]
length, frm, to = [], [], []
for _ in range(M):
    p, q = map(int1, input().split())
    length.append(((P[p][0] - P[q][0]) ** 2 + (P[p][1] - P[q][1]) ** 2) ** .5)
    frm.append(p)
    to.append(q)

matr = csr_matrix((length, (frm, to)), shape=(N, N))
print(dijkstra(matr, indices=X, directed=False)[Y])
0