結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-05-29 21:48:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 949 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 82,512 KB |
実行使用メモリ | 146,288 KB |
最終ジャッジ日時 | 2024-11-06 03:46:06 |
合計ジャッジ時間 | 21,463 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
import sys input = sys.stdin.readline N,M=map(int,input().split()) X,Y=map(int,input().split()) L=[tuple(map(int,input().split())) for i in range(N)] E=[[] for i in range(N+1)] from math import sqrt for i in range(M): p,q=map(int,input().split()) p-=1 q-=1 x0,y0=L[p] x1,y1=L[q] E[p].append((sqrt((x0-x1)**2+(y0-y1)**2),q)) E[q].append((sqrt((x0-x1)**2+(y0-y1)**2),p)) import heapq DP=[1<<62]*(N+1) DP[X-1]=0 Q=[(0,X-1)] while Q: now,x=heapq.heappop(Q) for le,to in E[x]: if DP[to]>DP[x]+le: DP[to]=DP[x]+le heapq.heappush(Q,(DP[to]+le,to)) print(DP[Y-1])