結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー titia
提出日時 2020-05-29 21:47:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 112,640 KB
最終ジャッジ日時 2024-11-06 03:35:20
合計ジャッジ時間 24,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 TLE * 7 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
    
    
    
    
0