結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2024-09-19 23:36:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,017 ms / 2,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 82,120 KB |
| 実行使用メモリ | 143,500 KB |
| 最終ジャッジ日時 | 2024-09-19 23:37:02 |
| 合計ジャッジ時間 | 23,135 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
n,m=map(int,input().split())
S,G=map(int,input().split())
S-=1
G-=1
p=[tuple(map(int,input().split())) for i in range(n)]
e=[[] for i in range(n)]
for i in range(m):
s,g=map(int,input().split())
s-=1
g-=1
sx,sy=p[s]
gx,gy=p[g]
d=((sx-gx)**2+(sy-gy)**2)**0.5
e[s]+=[(g,d)]
e[g]+=[(s,d)]
from heapq import heappush,heappop
X=10**20
v=[X]*n
v[S]=0
q=[(v[S],S)]
while len(q)>0:
sc,sp=heappop(q)
if sc>v[sp]:
continue
for tp,tc in e[sp]:
if v[tp]>sc+tc:
v[tp]=sc+tc
heappush(q,(v[tp],tp))
print(v[G])
sasa8uyauya