結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー roarisroaris
提出日時 2020-06-27 07:52:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 940 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 140,600 KB
最終ジャッジ日時 2023-09-18 19:02:46
合計ジャッジ時間 22,802 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,556 KB
testcase_01 AC 75 ms
71,400 KB
testcase_02 AC 538 ms
110,632 KB
testcase_03 AC 670 ms
138,688 KB
testcase_04 AC 657 ms
137,904 KB
testcase_05 AC 462 ms
136,004 KB
testcase_06 AC 466 ms
135,884 KB
testcase_07 AC 171 ms
90,644 KB
testcase_08 AC 383 ms
139,480 KB
testcase_09 AC 126 ms
82,904 KB
testcase_10 AC 226 ms
104,696 KB
testcase_11 AC 185 ms
95,856 KB
testcase_12 AC 165 ms
87,744 KB
testcase_13 AC 672 ms
118,268 KB
testcase_14 AC 724 ms
124,896 KB
testcase_15 AC 794 ms
133,216 KB
testcase_16 AC 432 ms
104,680 KB
testcase_17 AC 875 ms
137,360 KB
testcase_18 AC 355 ms
96,604 KB
testcase_19 AC 846 ms
135,140 KB
testcase_20 AC 299 ms
93,360 KB
testcase_21 AC 405 ms
101,320 KB
testcase_22 AC 792 ms
128,416 KB
testcase_23 AC 89 ms
77,064 KB
testcase_24 AC 93 ms
77,232 KB
testcase_25 AC 155 ms
87,888 KB
testcase_26 AC 476 ms
108,392 KB
testcase_27 AC 521 ms
107,704 KB
testcase_28 AC 807 ms
128,120 KB
testcase_29 AC 198 ms
84,468 KB
testcase_30 AC 820 ms
132,320 KB
testcase_31 AC 586 ms
117,376 KB
testcase_32 AC 429 ms
103,208 KB
testcase_33 AC 909 ms
134,160 KB
testcase_34 AC 402 ms
98,236 KB
testcase_35 AC 813 ms
134,852 KB
testcase_36 AC 106 ms
78,132 KB
testcase_37 AC 131 ms
78,664 KB
testcase_38 AC 109 ms
78,244 KB
testcase_39 AC 132 ms
78,604 KB
testcase_40 AC 86 ms
76,020 KB
testcase_41 AC 940 ms
140,600 KB
testcase_42 AC 349 ms
97,324 KB
testcase_43 AC 531 ms
111,328 KB
testcase_44 AC 261 ms
90,808 KB
testcase_45 AC 506 ms
110,568 KB
testcase_46 AC 75 ms
71,356 KB
testcase_47 AC 75 ms
71,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

def dijkstra():
    dist = [10**18]*N
    dist[X-1] = 0
    pq = []
    heappush(pq, (dist[X-1], X-1))
    
    while pq:
        d, v = heappop(pq)
        
        if dist[v]<d:
            continue
        
        for nv, w in G[v]:
            if dist[nv]>dist[v]+w:
                dist[nv] = dist[v]+w
                heappush(pq, (dist[nv], nv))
    
    return dist

N, M = map(int, input().split())
X, Y = map(int, input().split())
pq = [tuple(map(int, input().split())) for _ in range(N)]
G = [[] for _ in range(N)]

for _ in range(M):
    s, t = map(int, input().split())
    ps, qs = pq[s-1]
    pt, qt = pq[t-1]
    d = ((ps-pt)**2+(qs-qt)**2)**0.5
    G[s-1].append((t-1, d))
    G[t-1].append((s-1, d))

print(dijkstra()[Y-1])
0