結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー |
![]() |
提出日時 | 2020-06-02 22:20:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 959 ms / 2,000 ms |
コード長 | 703 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 142,336 KB |
最終ジャッジ日時 | 2024-11-24 14:37:13 |
合計ジャッジ時間 | 17,148 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
from math import sqrtfrom sys import stdinfrom collections import dequereadline = stdin.readlineN, 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')] * Nt[X] = 0while 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] = kq.append(j)print(t[Y])