結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-05-29 22:50:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 754 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 136,480 KB
最終ジャッジ日時 2024-04-24 00:26:31
合計ジャッジ時間 18,253 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,864 KB
testcase_01 AC 44 ms
52,864 KB
testcase_02 AC 407 ms
105,244 KB
testcase_03 AC 589 ms
136,480 KB
testcase_04 AC 563 ms
134,696 KB
testcase_05 AC 394 ms
134,532 KB
testcase_06 AC 402 ms
134,528 KB
testcase_07 AC 132 ms
90,152 KB
testcase_08 AC 290 ms
133,008 KB
testcase_09 AC 92 ms
78,960 KB
testcase_10 AC 173 ms
100,980 KB
testcase_11 AC 137 ms
89,744 KB
testcase_12 AC 134 ms
88,820 KB
testcase_13 AC 546 ms
115,020 KB
testcase_14 AC 579 ms
120,752 KB
testcase_15 AC 676 ms
129,880 KB
testcase_16 AC 382 ms
102,288 KB
testcase_17 AC 712 ms
132,080 KB
testcase_18 AC 279 ms
95,252 KB
testcase_19 AC 679 ms
129,340 KB
testcase_20 AC 242 ms
90,240 KB
testcase_21 AC 297 ms
100,864 KB
testcase_22 AC 652 ms
125,456 KB
testcase_23 AC 57 ms
67,456 KB
testcase_24 AC 63 ms
69,632 KB
testcase_25 AC 128 ms
88,376 KB
testcase_26 AC 387 ms
105,868 KB
testcase_27 AC 436 ms
105,472 KB
testcase_28 AC 669 ms
125,936 KB
testcase_29 AC 168 ms
83,584 KB
testcase_30 AC 671 ms
128,324 KB
testcase_31 AC 484 ms
113,444 KB
testcase_32 AC 344 ms
101,044 KB
testcase_33 AC 737 ms
129,944 KB
testcase_34 AC 307 ms
96,212 KB
testcase_35 AC 678 ms
129,804 KB
testcase_36 AC 73 ms
71,552 KB
testcase_37 AC 108 ms
77,808 KB
testcase_38 AC 77 ms
72,448 KB
testcase_39 AC 109 ms
77,312 KB
testcase_40 AC 55 ms
62,848 KB
testcase_41 AC 754 ms
132,940 KB
testcase_42 AC 279 ms
94,144 KB
testcase_43 AC 410 ms
105,760 KB
testcase_44 AC 191 ms
88,064 KB
testcase_45 AC 403 ms
105,324 KB
testcase_46 AC 40 ms
52,608 KB
testcase_47 AC 38 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys;input=sys.stdin.readline
from heapq import *
def dijkstra_heapq(s, cost):
    d = [float("inf")] * N
    h = [(0, s)]
    d[s] = 0
    while h:
        vc, v = heappop(h)
#        print(h)
        if vc > d[v]:
            continue
        for j, c in cost[v]:
            if vc+c<d[j]:
                d[j] = vc+c
                heappush(h, (vc+c, j))
    return d

N, M = map(int,input().split())
X, Y = map(int,input().split())
V = []
for _ in range(N):
    p, q = map(int, input().split())
    V.append((p, q))

cost = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    a, b = V[A-1]
    c, d = V[B-1]
    cost[A-1].append((B-1, ((a-c)**2+(b-d)**2)**0.5))
    cost[B-1].append((A-1, ((a-c)**2+(b-d)**2)**0.5))

d = dijkstra_heapq(X-1,cost)
print(d[Y-1])

0