結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー H3PO4H3PO4
提出日時 2020-05-29 23:27:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,881 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 121,180 KB
最終ジャッジ日時 2024-04-24 01:40:00
合計ジャッジ時間 65,199 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 807 ms
53,640 KB
testcase_01 AC 828 ms
53,824 KB
testcase_02 AC 1,325 ms
85,988 KB
testcase_03 AC 1,660 ms
106,664 KB
testcase_04 AC 1,640 ms
106,808 KB
testcase_05 AC 1,480 ms
99,680 KB
testcase_06 AC 1,490 ms
99,284 KB
testcase_07 AC 1,038 ms
70,900 KB
testcase_08 AC 1,662 ms
121,180 KB
testcase_09 AC 889 ms
57,824 KB
testcase_10 AC 1,179 ms
82,564 KB
testcase_11 AC 1,075 ms
73,192 KB
testcase_12 AC 1,065 ms
64,308 KB
testcase_13 AC 1,432 ms
84,880 KB
testcase_14 AC 1,488 ms
90,740 KB
testcase_15 AC 1,610 ms
96,268 KB
testcase_16 AC 1,243 ms
73,308 KB
testcase_17 AC 1,761 ms
100,632 KB
testcase_18 AC 1,308 ms
67,568 KB
testcase_19 AC 1,653 ms
99,028 KB
testcase_20 AC 1,039 ms
65,636 KB
testcase_21 AC 1,200 ms
70,848 KB
testcase_22 AC 1,579 ms
94,208 KB
testcase_23 AC 856 ms
53,752 KB
testcase_24 AC 833 ms
53,784 KB
testcase_25 AC 1,039 ms
62,404 KB
testcase_26 AC 1,301 ms
78,320 KB
testcase_27 AC 1,564 ms
77,536 KB
testcase_28 AC 1,707 ms
93,228 KB
testcase_29 AC 940 ms
57,572 KB
testcase_30 AC 1,639 ms
97,892 KB
testcase_31 AC 1,420 ms
85,056 KB
testcase_32 AC 1,176 ms
73,972 KB
testcase_33 AC 1,588 ms
95,536 KB
testcase_34 AC 1,158 ms
69,092 KB
testcase_35 AC 1,685 ms
98,156 KB
testcase_36 AC 829 ms
54,128 KB
testcase_37 AC 840 ms
53,864 KB
testcase_38 AC 840 ms
53,992 KB
testcase_39 AC 827 ms
53,816 KB
testcase_40 AC 828 ms
53,664 KB
testcase_41 AC 1,881 ms
120,436 KB
testcase_42 AC 1,140 ms
73,716 KB
testcase_43 AC 1,477 ms
89,224 KB
testcase_44 AC 1,017 ms
65,256 KB
testcase_45 AC 1,358 ms
87,992 KB
testcase_46 AC 837 ms
53,512 KB
testcase_47 AC 839 ms
53,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

input = sys.stdin.readline

int1 = lambda x: int(x) - 1


def main():
    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 = [.0] * M, [0] * M, [0] * M
    for i in range(M):
        p, q = map(int1, input().split())
        length[i] = ((P[p][0] - P[q][0]) ** 2 + (P[p][1] - P[q][1]) ** 2) ** .5
        frm[i] = p
        to[i] = q

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


if __name__ == '__main__':
    main()
0