結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー c-yanc-yan
提出日時 2020-05-30 00:33:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 627 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 142,672 KB
最終ジャッジ日時 2024-04-24 03:11:50
合計ジャッジ時間 13,948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
54,016 KB
testcase_01 AC 48 ms
54,352 KB
testcase_02 AC 281 ms
109,092 KB
testcase_03 AC 345 ms
140,784 KB
testcase_04 AC 306 ms
140,772 KB
testcase_05 AC 271 ms
142,328 KB
testcase_06 AC 276 ms
142,672 KB
testcase_07 AC 124 ms
88,704 KB
testcase_08 AC 305 ms
141,656 KB
testcase_09 AC 108 ms
80,740 KB
testcase_10 AC 171 ms
105,372 KB
testcase_11 AC 138 ms
93,324 KB
testcase_12 AC 112 ms
87,808 KB
testcase_13 AC 448 ms
113,024 KB
testcase_14 AC 399 ms
120,380 KB
testcase_15 AC 499 ms
128,964 KB
testcase_16 AC 263 ms
99,696 KB
testcase_17 AC 627 ms
132,480 KB
testcase_18 AC 223 ms
91,776 KB
testcase_19 AC 555 ms
130,432 KB
testcase_20 AC 182 ms
91,008 KB
testcase_21 AC 258 ms
96,512 KB
testcase_22 AC 427 ms
124,288 KB
testcase_23 AC 69 ms
69,888 KB
testcase_24 AC 72 ms
72,704 KB
testcase_25 AC 124 ms
87,936 KB
testcase_26 AC 330 ms
108,416 KB
testcase_27 AC 288 ms
105,856 KB
testcase_28 AC 420 ms
127,744 KB
testcase_29 AC 124 ms
82,816 KB
testcase_30 AC 481 ms
134,528 KB
testcase_31 AC 267 ms
110,464 KB
testcase_32 AC 202 ms
99,712 KB
testcase_33 AC 376 ms
133,120 KB
testcase_34 AC 208 ms
94,208 KB
testcase_35 AC 452 ms
135,808 KB
testcase_36 AC 74 ms
70,656 KB
testcase_37 AC 82 ms
73,856 KB
testcase_38 AC 74 ms
70,784 KB
testcase_39 AC 87 ms
77,440 KB
testcase_40 AC 61 ms
66,304 KB
testcase_41 AC 523 ms
141,952 KB
testcase_42 AC 202 ms
93,184 KB
testcase_43 AC 290 ms
106,752 KB
testcase_44 AC 158 ms
87,168 KB
testcase_45 AC 294 ms
110,336 KB
testcase_46 AC 45 ms
53,888 KB
testcase_47 AC 45 ms
54,016 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