結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー GrayCoder
提出日時 2025-08-12 19:00:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 805 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 92,316 KB
最終ジャッジ日時 2025-08-12 19:01:22
合計ジャッジ時間 10,820 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 TLE * 6 -- * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path
import sys


def main():
    input = lambda: sys.stdin.readline()[:-1]
    N, M = map(int, input().split())
    X, Y = map(int, input().split())
    pq = np.array([input().split() for _ in [0] * N], dtype=np.int64)
    PQ = np.transpose(np.fromstring(sys.stdin.read(), dtype=np.int64, sep=" ").reshape(-1, 2))

    func = np.vectorize(lambda p, q: np.linalg.norm([pq[p - 1] - pq[q - 1]]))
    dist = func(PQ[0], PQ[1])
    csr = csr_matrix((dist, PQ), (N + 1, N + 1))
    ans = shortest_path(csr, indices=X, directed=False)
    print(ans[Y])


if not __debug__:
    f = open(sys.argv[1], "r")
    sys.stdin = f

# try:
#     sys.set_int_max_str_digits(100000)
# except AttributeError:
#     pass

main()
0