結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー H3PO4H3PO4
提出日時 2021-10-07 10:32:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 926 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 140,380 KB
最終ジャッジ日時 2023-09-30 09:01:37
合計ジャッジ時間 28,216 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,608 KB
testcase_01 AC 71 ms
71,492 KB
testcase_02 AC 523 ms
109,724 KB
testcase_03 AC 651 ms
137,420 KB
testcase_04 AC 738 ms
137,876 KB
testcase_05 AC 450 ms
135,376 KB
testcase_06 AC 454 ms
135,180 KB
testcase_07 AC 167 ms
91,944 KB
testcase_08 AC 366 ms
138,496 KB
testcase_09 AC 136 ms
82,624 KB
testcase_10 AC 227 ms
105,916 KB
testcase_11 AC 186 ms
96,640 KB
testcase_12 AC 169 ms
90,012 KB
testcase_13 AC 684 ms
118,272 KB
testcase_14 AC 730 ms
124,592 KB
testcase_15 AC 839 ms
133,696 KB
testcase_16 AC 483 ms
104,884 KB
testcase_17 AC 896 ms
138,060 KB
testcase_18 AC 376 ms
96,660 KB
testcase_19 AC 824 ms
134,920 KB
testcase_20 AC 304 ms
93,024 KB
testcase_21 AC 422 ms
101,296 KB
testcase_22 AC 799 ms
128,720 KB
testcase_23 AC 93 ms
77,044 KB
testcase_24 AC 101 ms
78,440 KB
testcase_25 AC 167 ms
86,236 KB
testcase_26 AC 485 ms
108,488 KB
testcase_27 AC 536 ms
108,212 KB
testcase_28 AC 846 ms
128,572 KB
testcase_29 AC 210 ms
85,304 KB
testcase_30 AC 891 ms
133,116 KB
testcase_31 AC 625 ms
117,500 KB
testcase_32 AC 436 ms
104,140 KB
testcase_33 AC 926 ms
134,200 KB
testcase_34 AC 406 ms
98,532 KB
testcase_35 AC 824 ms
133,620 KB
testcase_36 AC 103 ms
77,908 KB
testcase_37 AC 131 ms
78,788 KB
testcase_38 AC 109 ms
78,144 KB
testcase_39 AC 140 ms
78,220 KB
testcase_40 AC 85 ms
76,460 KB
testcase_41 AC 904 ms
140,380 KB
testcase_42 AC 330 ms
97,532 KB
testcase_43 AC 525 ms
110,868 KB
testcase_44 AC 263 ms
90,548 KB
testcase_45 AC 505 ms
110,892 KB
testcase_46 AC 74 ms
71,500 KB
testcase_47 AC 73 ms
71,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

from heapq import heappush, heappop

input = sys.stdin.buffer.readline

N, M = map(int, input().split())
X, Y = (int(x) - 1 for x in input().split())
INF = 10 ** 10


def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(que, (dist[t], t))
    return dist


points = [tuple(map(int, input().split())) for _ in range(N)]


def euc_dist(p, q):
    px, py = points[p]
    qx, qy = points[q]
    return ((px - qx) ** 2 + (py - qy) ** 2) ** .5


G = [[] for _ in range(N)]
for _ in range(M):
    p, q = (int(x) - 1 for x in input().split())
    d = euc_dist(p, q)
    G[p].append((q, d))
    G[q].append((p, d))

print(dijkstra(N, G, X)[Y])
0