結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2020-05-29 21:41:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 921 ms / 2,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 142,572 KB |
| 最終ジャッジ日時 | 2024-11-06 03:10:08 |
| 合計ジャッジ時間 | 15,876 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
from math import sqrt
from sys import stdin
from collections import deque
readline = stdin.readline
N, M = map(int, readline().split())
X, Y = map(lambda x: int(x) - 1, readline().split())
pq = [list(map(int, readline().split())) for _ in range(N)]
PQ = [list(map(int, readline().split())) for _ in range(M)]
links = [[] for _ in range(N)]
for P, Q in PQ:
links[P - 1].append(Q - 1)
links[Q - 1].append(P - 1)
q = deque([X])
t = [float('inf')] * N
t[X] = 0
while q:
i = q.popleft()
for j in links[i]:
a, b = pq[i]
c, d = pq[j]
k = t[i] + sqrt((a - c) * (a -c) + (b - d) * (b - d))
if k < t[j]:
t[j] = k
q.append(j)
print(t[Y])
c-yan