結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー c-yanc-yan
提出日時 2020-05-29 21:41:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 536 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 142,384 KB
最終ジャッジ日時 2024-04-23 20:50:52
合計ジャッジ時間 12,006 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,888 KB
testcase_01 AC 41 ms
54,272 KB
testcase_02 AC 233 ms
109,064 KB
testcase_03 AC 250 ms
140,788 KB
testcase_04 AC 265 ms
140,856 KB
testcase_05 AC 248 ms
142,384 KB
testcase_06 AC 252 ms
142,312 KB
testcase_07 AC 119 ms
88,824 KB
testcase_08 AC 262 ms
141,952 KB
testcase_09 AC 85 ms
80,976 KB
testcase_10 AC 171 ms
105,572 KB
testcase_11 AC 124 ms
93,436 KB
testcase_12 AC 101 ms
87,632 KB
testcase_13 AC 384 ms
112,904 KB
testcase_14 AC 316 ms
120,268 KB
testcase_15 AC 432 ms
129,348 KB
testcase_16 AC 259 ms
99,796 KB
testcase_17 AC 536 ms
132,584 KB
testcase_18 AC 187 ms
91,932 KB
testcase_19 AC 485 ms
129,828 KB
testcase_20 AC 151 ms
90,772 KB
testcase_21 AC 231 ms
96,716 KB
testcase_22 AC 366 ms
124,144 KB
testcase_23 AC 55 ms
70,532 KB
testcase_24 AC 57 ms
73,088 KB
testcase_25 AC 103 ms
87,784 KB
testcase_26 AC 277 ms
108,148 KB
testcase_27 AC 242 ms
105,932 KB
testcase_28 AC 358 ms
127,652 KB
testcase_29 AC 101 ms
82,928 KB
testcase_30 AC 380 ms
134,244 KB
testcase_31 AC 227 ms
110,744 KB
testcase_32 AC 174 ms
99,932 KB
testcase_33 AC 308 ms
132,828 KB
testcase_34 AC 174 ms
94,100 KB
testcase_35 AC 385 ms
135,540 KB
testcase_36 AC 66 ms
71,088 KB
testcase_37 AC 70 ms
73,856 KB
testcase_38 AC 66 ms
71,168 KB
testcase_39 AC 68 ms
77,404 KB
testcase_40 AC 51 ms
66,560 KB
testcase_41 AC 444 ms
141,688 KB
testcase_42 AC 170 ms
93,352 KB
testcase_43 AC 236 ms
106,456 KB
testcase_44 AC 126 ms
86,952 KB
testcase_45 AC 244 ms
109,828 KB
testcase_46 AC 37 ms
54,404 KB
testcase_47 AC 35 ms
54,168 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