結果
| 問題 | No.1065 電柱 / Pole (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-22 22:30:22 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,367 ms / 2,000 ms |
| + 927µs | |
| コード長 | 636 bytes |
| 記録 | |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 64,968 KB |
| 実行使用メモリ | 161,756 KB |
| 最終ジャッジ日時 | 2026-10-15 13:34:31 |
| 合計ジャッジ時間 | 26,553 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
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])