結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pluto77
提出日時 2020-06-19 14:30:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,788 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 142,828 KB
最終ジャッジ日時 2024-07-03 13:23:50
合計ジャッジ時間 28,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1065
from collections import deque
from math import *

N,M=map(int,input().split())
X,Y=map(int,input().split())
X-=1
Y-=1
pq=[list(map(int,input().split())) for i in range(N)]
PQ=[list(map(int,input().split())) for i in range(M)]
edge=[[] for i in range(N)]
for P,Q in PQ:
 edge[P-1].append(Q-1)
 edge[Q-1].append(P-1)

q=deque([X])
res=[float('inf')]*N
res[X]=0
while q:
 i=q.popleft()
 for j in edge[i]:
  a,b=pq[i]
  c,d=pq[j]
  k=res[i]+hypot(a-c,b-d)
  if k<res[j]:
   res[j]=k
   q.append(j)
print(res[Y])
0