結果
| 問題 | No.1065 電柱 / Pole (Easy) |
| コンテスト | |
| ユーザー |
paruf4
|
| 提出日時 | 2020-05-29 22:37:44 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,360 ms / 2,000 ms |
| コード長 | 694 bytes |
| 記録 | |
| コンパイル時間 | 394 ms |
| コンパイル使用メモリ | 85,352 KB |
| 実行使用メモリ | 163,524 KB |
| 最終ジャッジ日時 | 2026-05-06 08:29:21 |
| 合計ジャッジ時間 | 24,088 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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