結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー c-yanc-yan
提出日時 2020-06-02 22:32:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 955 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 144,544 KB
最終ジャッジ日時 2023-08-16 05:09:12
合計ジャッジ時間 18,990 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,844 KB
testcase_01 AC 79 ms
72,124 KB
testcase_02 AC 315 ms
105,924 KB
testcase_03 AC 406 ms
143,952 KB
testcase_04 AC 496 ms
144,544 KB
testcase_05 AC 312 ms
142,764 KB
testcase_06 AC 310 ms
142,752 KB
testcase_07 AC 170 ms
93,568 KB
testcase_08 AC 369 ms
143,640 KB
testcase_09 AC 130 ms
84,952 KB
testcase_10 AC 213 ms
100,356 KB
testcase_11 AC 187 ms
98,280 KB
testcase_12 AC 169 ms
90,500 KB
testcase_13 AC 656 ms
114,964 KB
testcase_14 AC 515 ms
122,140 KB
testcase_15 AC 765 ms
129,512 KB
testcase_16 AC 430 ms
100,812 KB
testcase_17 AC 955 ms
136,264 KB
testcase_18 AC 321 ms
94,872 KB
testcase_19 AC 817 ms
133,648 KB
testcase_20 AC 250 ms
92,468 KB
testcase_21 AC 390 ms
99,544 KB
testcase_22 AC 559 ms
126,412 KB
testcase_23 AC 96 ms
78,184 KB
testcase_24 AC 102 ms
78,444 KB
testcase_25 AC 157 ms
87,596 KB
testcase_26 AC 460 ms
110,288 KB
testcase_27 AC 373 ms
107,840 KB
testcase_28 AC 545 ms
129,340 KB
testcase_29 AC 167 ms
83,108 KB
testcase_30 AC 576 ms
128,744 KB
testcase_31 AC 340 ms
114,352 KB
testcase_32 AC 261 ms
104,248 KB
testcase_33 AC 439 ms
133,196 KB
testcase_34 AC 283 ms
95,268 KB
testcase_35 AC 577 ms
136,772 KB
testcase_36 AC 106 ms
78,588 KB
testcase_37 AC 109 ms
78,464 KB
testcase_38 AC 103 ms
78,448 KB
testcase_39 AC 114 ms
78,628 KB
testcase_40 AC 100 ms
78,236 KB
testcase_41 AC 589 ms
143,652 KB
testcase_42 AC 245 ms
98,516 KB
testcase_43 AC 359 ms
112,440 KB
testcase_44 AC 202 ms
91,592 KB
testcase_45 AC 343 ms
112,012 KB
testcase_46 AC 81 ms
72,052 KB
testcase_47 AC 81 ms
72,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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] + ((a - c) * (a -c) + (b - d) * (b - d)) ** 0.5
        if k < t[j]:
            t[j] = k
            q.append(j)
print(t[Y])
0