結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-05-29 22:37:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 694 bytes |
コンパイル時間 | 241 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 114,048 KB |
最終ジャッジ日時 | 2024-11-06 06:20:02 |
合計ジャッジ時間 | 29,923 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 9 -- * 30 |
ソースコード
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])