結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-05-29 22:39:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,179 ms / 2,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 340 ms |
コンパイル使用メモリ | 82,592 KB |
実行使用メモリ | 158,240 KB |
最終ジャッジ日時 | 2024-11-06 06:30:06 |
合計ジャッジ時間 | 25,070 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
import sys input=sys.stdin.readline 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=[tuple(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])