結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー c-yanc-yan
提出日時 2020-06-02 22:20:04
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,050 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 144,072 KB
最終ジャッジ日時 2023-08-16 04:49:47
合計ジャッジ時間 20,444 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,600 KB
testcase_01 AC 105 ms
71,672 KB
testcase_02 AC 408 ms
105,436 KB
testcase_03 AC 386 ms
144,072 KB
testcase_04 AC 400 ms
144,016 KB
testcase_05 AC 361 ms
142,140 KB
testcase_06 AC 363 ms
142,448 KB
testcase_07 AC 195 ms
93,324 KB
testcase_08 AC 388 ms
143,140 KB
testcase_09 AC 154 ms
83,936 KB
testcase_10 AC 237 ms
99,868 KB
testcase_11 AC 208 ms
97,768 KB
testcase_12 AC 182 ms
90,128 KB
testcase_13 AC 735 ms
114,584 KB
testcase_14 AC 568 ms
121,536 KB
testcase_15 AC 820 ms
128,768 KB
testcase_16 AC 415 ms
100,296 KB
testcase_17 AC 1,050 ms
135,436 KB
testcase_18 AC 296 ms
94,308 KB
testcase_19 AC 892 ms
133,144 KB
testcase_20 AC 250 ms
87,904 KB
testcase_21 AC 360 ms
98,832 KB
testcase_22 AC 629 ms
125,596 KB
testcase_23 AC 123 ms
78,040 KB
testcase_24 AC 121 ms
77,976 KB
testcase_25 AC 174 ms
87,372 KB
testcase_26 AC 453 ms
109,696 KB
testcase_27 AC 439 ms
107,296 KB
testcase_28 AC 626 ms
128,372 KB
testcase_29 AC 175 ms
82,640 KB
testcase_30 AC 649 ms
128,548 KB
testcase_31 AC 377 ms
114,144 KB
testcase_32 AC 292 ms
103,656 KB
testcase_33 AC 466 ms
132,692 KB
testcase_34 AC 307 ms
94,840 KB
testcase_35 AC 606 ms
136,456 KB
testcase_36 AC 125 ms
78,152 KB
testcase_37 AC 129 ms
78,248 KB
testcase_38 AC 125 ms
78,228 KB
testcase_39 AC 135 ms
77,988 KB
testcase_40 AC 118 ms
77,720 KB
testcase_41 AC 650 ms
142,868 KB
testcase_42 AC 277 ms
97,980 KB
testcase_43 AC 387 ms
112,212 KB
testcase_44 AC 230 ms
90,920 KB
testcase_45 AC 381 ms
111,568 KB
testcase_46 AC 102 ms
71,592 KB
testcase_47 AC 103 ms
71,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
from sys import stdin
from collections import deque

readline = stdin.readline

N, M = map(int, readline().split())
X, Y = map(lambda x: int(x) - 1, readline().split())
pq = [list(map(int, readline().split())) for _ in range(N)]
PQ = [list(map(int, readline().split())) for _ in range(M)]

links = [[] for _ in range(N)]
for P, Q in PQ:
    links[P - 1].append(Q - 1)
    links[Q - 1].append(P - 1)

q = deque([X])
t = [float('inf')] * N
t[X] = 0
while q:
    i = q.popleft()
    for j in links[i]:
        a, b = pq[i]
        c, d = pq[j]
        k = t[i] + sqrt((a - c) * (a -c) + (b - d) * (b - d))
        if k < t[j]:
            t[j] = k
            q.append(j)
print(t[Y])
0