結果
| 問題 | No.1065 電柱 / Pole (Easy) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-01-31 04:04:13 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 930 ms / 2,000 ms | 
| コード長 | 1,306 bytes | 
| コンパイル時間 | 234 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 146,688 KB | 
| 最終ジャッジ日時 | 2024-06-28 15:05:01 | 
| 合計ジャッジ時間 | 26,232 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 46 | 
ソースコード
#region Header
#!/usr/bin/env python3
# from typing import *
import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
#endregion
# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)
def main():
    N, M = map(int, input().split())
    X, Y = map(lambda x: int(x)-1, input().split())
    G = [list() for _ in range(N)]
    P = []
    for _ in range(N):
        _x, _y = map(int, input().split())
        P.append((_x, _y))
    for _ in range(M):
        _p, _q = map(lambda x: int(x)-1, input().split())
        d = math.sqrt((P[_p][0] - P[_q][0]) ** 2 + (P[_p][1] - P[_q][1]) ** 2)
        G[_p].append((_q, d))
        G[_q].append((_p, d))
    # K を始点とする
    dist = [10**20 for _ in range(N)]
    hq = []
    heapq.heappush(hq, (0, X))
    dist[X] = 0
    while hq:
        d, p = heapq.heappop(hq)
        if d > dist[p]:
            continue
        for (p1, w1) in G[p]:
            d1 = dist[p] + w1
            if d1 < dist[p1]:
                dist[p1] = d1
                heapq.heappush(hq, (dist[p1], p1))
    print(dist[Y])
if __name__ == '__main__':
    main()
            
            
            
        