結果
| 問題 | No.1065 電柱 / Pole (Easy) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-19 13:12:39 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,227 ms / 2,000 ms | 
| コード長 | 677 bytes | 
| コンパイル時間 | 151 ms | 
| コンパイル使用メモリ | 82,528 KB | 
| 実行使用メモリ | 161,100 KB | 
| 最終ジャッジ日時 | 2024-07-03 13:18:22 | 
| 合計ジャッジ時間 | 28,909 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 46 | 
ソースコード
#yuki1065
from heapq import heappop,heappush
def dijkstra(s,n,edge):
 dist=[float("inf")]*n
 dist[s]=0
 used=[-1]*n
 hq=[[dist[s],s]]
 while hq:
  d,cur=heappop(hq)
  if dist[cur]<d:
   continue
  for nx,nxd in edge[cur]:
   if dist[cur]+nxd<dist[nx]:
    dist[nx]=dist[cur]+nxd
    used[nx]=cur
    heappush(hq,[dist[cur]+nxd,nx])
 return dist
  
n,m=map(int,input().split())
x,y=map(int,input().split())
pq=[list(map(int,input().split())) for i in range(n)]
G=[[] for i in range(n)]
for i in range(m):
 p,q=map(int,input().split())
 p-=1
 q-=1
 c=((pq[q][0]-pq[p][0])**2+(pq[q][1]-pq[p][1])**2)**0.5
 G[p].append([q,c])
 G[q].append([p,c])
d=dijkstra(x-1,n,G)
print(d[y-1])
            
            
            
        