結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー nephrologistnephrologist
提出日時 2020-05-29 21:46:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 946 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 148,964 KB
最終ジャッジ日時 2024-04-23 21:11:17
合計ジャッジ時間 19,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,248 KB
testcase_01 AC 44 ms
52,864 KB
testcase_02 AC 345 ms
109,396 KB
testcase_03 AC 618 ms
146,548 KB
testcase_04 AC 797 ms
148,964 KB
testcase_05 AC 500 ms
145,420 KB
testcase_06 AC 519 ms
145,548 KB
testcase_07 AC 127 ms
90,112 KB
testcase_08 AC 317 ms
141,696 KB
testcase_09 AC 90 ms
78,848 KB
testcase_10 AC 168 ms
103,296 KB
testcase_11 AC 145 ms
96,948 KB
testcase_12 AC 138 ms
90,232 KB
testcase_13 AC 614 ms
124,388 KB
testcase_14 AC 583 ms
129,880 KB
testcase_15 AC 946 ms
138,128 KB
testcase_16 AC 368 ms
108,012 KB
testcase_17 AC 874 ms
143,268 KB
testcase_18 AC 357 ms
100,780 KB
testcase_19 AC 650 ms
139,140 KB
testcase_20 AC 305 ms
93,824 KB
testcase_21 AC 435 ms
106,652 KB
testcase_22 AC 734 ms
134,936 KB
testcase_23 AC 89 ms
77,312 KB
testcase_24 AC 56 ms
65,792 KB
testcase_25 AC 135 ms
89,088 KB
testcase_26 AC 315 ms
107,408 KB
testcase_27 AC 358 ms
110,036 KB
testcase_28 AC 552 ms
132,644 KB
testcase_29 AC 176 ms
85,248 KB
testcase_30 AC 565 ms
135,500 KB
testcase_31 AC 572 ms
120,524 KB
testcase_32 AC 266 ms
102,656 KB
testcase_33 AC 774 ms
138,016 KB
testcase_34 AC 353 ms
100,792 KB
testcase_35 AC 499 ms
132,992 KB
testcase_36 AC 58 ms
65,536 KB
testcase_37 AC 74 ms
73,216 KB
testcase_38 AC 68 ms
70,272 KB
testcase_39 AC 66 ms
69,888 KB
testcase_40 AC 48 ms
55,936 KB
testcase_41 AC 828 ms
143,480 KB
testcase_42 AC 282 ms
97,324 KB
testcase_43 AC 403 ms
111,872 KB
testcase_44 AC 184 ms
89,344 KB
testcase_45 AC 464 ms
111,308 KB
testcase_46 AC 41 ms
52,864 KB
testcase_47 AC 42 ms
52,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
from heapq import heappush, heappop
import sys

input = sys.stdin.buffer.readline

n, m = map(int, input().split())
x, y = map(int, input().split())
x -= 1
y -= 1


def kyori(a, b, c, d):
    return sqrt((a - c) ** 2 + (b - d) ** 2)


XY = [list(map(int, input().split())) for _ in range(n)]
graph = [[] for _ in range(n)]
for _ in range(m):
    p, q = map(int, input().split())
    a, b = XY[p - 1]
    c, d = XY[q - 1]
    temp = kyori(a, b, c, d)
    graph[p - 1].append((temp, q - 1))
    graph[q - 1].append((temp, p - 1))


edgelist = [(0, x)]
dist = [10 ** 10] * n
used = [False] * n
while edgelist:
    nowd, nowedge = heappop(edgelist)
    if used[nowedge]:
        continue
    if nowedge == y:
        print(nowd)
        exit()
    used[nowedge] = True
    dist[nowedge] = nowd
    for delta, nextedge in graph[nowedge]:
        if used[nextedge]:
            continue
        heappush(edgelist, (nowd + delta, nextedge))

print("error")
exit()
0