結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
|
提出日時 | 2022-03-22 22:30:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,427 ms / 2,000 ms |
コード長 | 636 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 150,712 KB |
最終ジャッジ日時 | 2024-10-10 16:56:01 |
合計ジャッジ時間 | 32,357 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
from heapq import heappop, heappush n,m = map(int,input().split()) x,y = map(int,input().split()) x,y = x-1,y-1 PQ = [list(map(int,input().split())) for i in range(n)] e = [[] for i in range(n)] for _ in range(m): p,q = [int(i)-1 for i in input().split()] x1,y1 = PQ[p] x2,y2 = PQ[q] dis = ((x1-x2)**2+(y1-y2)**2)**0.5 e[p].append((q,dis)) e[q].append((p,dis)) inf = 10**10 dis = [inf]*n dis[x] = 0 h = [[0,x]] while h: d,now = heappop(h) if dis[now] != d: continue for nex,c in e[now]: if dis[nex] > d+c: dis[nex] = d+c heappush(h,[d+c,nex]) print(dis[y])