結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
paruf4
|
| 提出日時 | 2020-05-29 22:37:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,530 ms / 2,000 ms |
| コード長 | 694 bytes |
| コンパイル時間 | 740 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 158,984 KB |
| 最終ジャッジ日時 | 2024-11-06 06:22:23 |
| 合計ジャッジ時間 | 33,212 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
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])
paruf4