結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー qibqib
提出日時 2022-10-23 03:34:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,038 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,576 KB
実行使用メモリ 144,868 KB
最終ジャッジ日時 2023-09-14 17:38:15
合計ジャッジ時間 28,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,524 KB
testcase_01 AC 77 ms
71,492 KB
testcase_02 AC 630 ms
111,500 KB
testcase_03 AC 797 ms
144,868 KB
testcase_04 AC 744 ms
144,468 KB
testcase_05 AC 578 ms
141,920 KB
testcase_06 AC 578 ms
142,276 KB
testcase_07 AC 227 ms
93,920 KB
testcase_08 AC 482 ms
140,644 KB
testcase_09 AC 166 ms
83,968 KB
testcase_10 AC 292 ms
105,004 KB
testcase_11 AC 244 ms
96,680 KB
testcase_12 AC 200 ms
89,044 KB
testcase_13 AC 713 ms
121,724 KB
testcase_14 AC 771 ms
128,540 KB
testcase_15 AC 928 ms
137,268 KB
testcase_16 AC 507 ms
106,364 KB
testcase_17 AC 973 ms
141,564 KB
testcase_18 AC 385 ms
97,940 KB
testcase_19 AC 878 ms
139,472 KB
testcase_20 AC 348 ms
94,412 KB
testcase_21 AC 441 ms
102,792 KB
testcase_22 AC 860 ms
133,708 KB
testcase_23 AC 108 ms
77,540 KB
testcase_24 AC 113 ms
77,644 KB
testcase_25 AC 191 ms
88,792 KB
testcase_26 AC 540 ms
110,416 KB
testcase_27 AC 595 ms
110,504 KB
testcase_28 AC 923 ms
133,376 KB
testcase_29 AC 244 ms
84,660 KB
testcase_30 AC 935 ms
137,768 KB
testcase_31 AC 662 ms
120,812 KB
testcase_32 AC 500 ms
105,820 KB
testcase_33 AC 1,019 ms
138,808 KB
testcase_34 AC 454 ms
99,248 KB
testcase_35 AC 907 ms
139,056 KB
testcase_36 AC 122 ms
78,668 KB
testcase_37 AC 173 ms
78,956 KB
testcase_38 AC 130 ms
78,992 KB
testcase_39 AC 170 ms
79,148 KB
testcase_40 AC 96 ms
76,524 KB
testcase_41 AC 1,038 ms
142,472 KB
testcase_42 AC 413 ms
97,656 KB
testcase_43 AC 597 ms
113,400 KB
testcase_44 AC 315 ms
90,568 KB
testcase_45 AC 591 ms
111,448 KB
testcase_46 AC 75 ms
71,564 KB
testcase_47 AC 75 ms
71,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import math

INF = 1e15

n, m = map(int, input().split())
src, dst = map(int, input().split())
src -= 1
dst -= 1
points = [list(map(int, input().split())) for _ in range(n)]

g = [[] for _ in range(n)]
for _ in range(m):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  xu, yu = points[u]
  xv, yv = points[v]
  d = math.sqrt((xv - xu) ** 2 + (yv - yu) ** 2)
  g[u].append((v, d))
  g[v].append((u, d))

dist = [INF for _ in range(n)]
dist[src] = 0.0
hp = [(0.0, src)]
while len(hp) > 0:
  cd, cur = heapq.heappop(hp)
  if cd > dist[cur]:
    continue

  for nxt, cost in g[cur]:
    if dist[cur] + cost < dist[nxt]:
      dist[nxt] = dist[cur] + cost
      heapq.heappush(hp, (dist[nxt], nxt))

print(dist[dst])
0