結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー H3PO4H3PO4
提出日時 2020-09-23 22:32:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 942 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 80,172 KB
最終ジャッジ日時 2023-09-10 13:09:21
合計ジャッジ時間 29,659 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
43,312 KB
testcase_01 AC 207 ms
43,484 KB
testcase_02 AC 640 ms
60,336 KB
testcase_03 AC 835 ms
78,528 KB
testcase_04 AC 824 ms
77,324 KB
testcase_05 AC 694 ms
78,804 KB
testcase_06 AC 689 ms
77,360 KB
testcase_07 AC 365 ms
53,500 KB
testcase_08 AC 790 ms
80,172 KB
testcase_09 AC 257 ms
47,552 KB
testcase_10 AC 470 ms
58,772 KB
testcase_11 AC 383 ms
54,608 KB
testcase_12 AC 369 ms
56,296 KB
testcase_13 AC 629 ms
65,916 KB
testcase_14 AC 703 ms
65,708 KB
testcase_15 AC 786 ms
69,792 KB
testcase_16 AC 486 ms
60,404 KB
testcase_17 AC 847 ms
72,484 KB
testcase_18 AC 417 ms
56,852 KB
testcase_19 AC 815 ms
70,256 KB
testcase_20 AC 367 ms
52,940 KB
testcase_21 AC 467 ms
61,176 KB
testcase_22 AC 753 ms
68,808 KB
testcase_23 AC 216 ms
44,116 KB
testcase_24 AC 217 ms
44,212 KB
testcase_25 AC 362 ms
54,752 KB
testcase_26 AC 527 ms
58,804 KB
testcase_27 AC 539 ms
60,976 KB
testcase_28 AC 751 ms
72,060 KB
testcase_29 AC 296 ms
48,160 KB
testcase_30 AC 826 ms
69,500 KB
testcase_31 AC 629 ms
60,948 KB
testcase_32 AC 477 ms
56,620 KB
testcase_33 AC 771 ms
67,756 KB
testcase_34 AC 421 ms
56,312 KB
testcase_35 AC 801 ms
71,036 KB
testcase_36 AC 205 ms
44,040 KB
testcase_37 AC 209 ms
44,344 KB
testcase_38 AC 211 ms
43,876 KB
testcase_39 AC 211 ms
44,304 KB
testcase_40 AC 202 ms
43,656 KB
testcase_41 AC 942 ms
78,104 KB
testcase_42 AC 422 ms
54,628 KB
testcase_43 AC 585 ms
61,884 KB
testcase_44 AC 343 ms
52,584 KB
testcase_45 AC 575 ms
61,200 KB
testcase_46 AC 208 ms
43,376 KB
testcase_47 AC 208 ms
43,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
from scipy.linalg import norm
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

input = sys.stdin.buffer.readline

int1 = lambda x: int(x) - 1


def main():
    N, M = map(int, input().split())
    X, Y = map(int1, input().split())
    pole = np.array([tuple(map(int, input().split())) for _ in range(N)])
    wire = np.array([tuple(map(int1, input().split())) for _ in range(M)]).T
    length = norm(pole[wire[0]] - pole[wire[1]], axis=1)
    matr = csr_matrix((length, wire), shape=(N, N))
    print(dijkstra(matr, indices=X, directed=False)[Y])


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