結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー mkawa2mkawa2
提出日時 2021-11-07 11:16:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 891 ms / 2,000 ms
コード長 1,314 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 143,708 KB
最終ジャッジ日時 2024-04-26 09:10:21
合計ジャッジ時間 21,121 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,120 KB
testcase_01 AC 41 ms
52,864 KB
testcase_02 AC 426 ms
109,152 KB
testcase_03 AC 558 ms
143,360 KB
testcase_04 AC 648 ms
143,708 KB
testcase_05 AC 436 ms
139,580 KB
testcase_06 AC 443 ms
139,216 KB
testcase_07 AC 157 ms
93,568 KB
testcase_08 AC 379 ms
141,324 KB
testcase_09 AC 106 ms
81,800 KB
testcase_10 AC 210 ms
105,344 KB
testcase_11 AC 178 ms
97,024 KB
testcase_12 AC 135 ms
88,576 KB
testcase_13 AC 611 ms
120,320 KB
testcase_14 AC 596 ms
127,104 KB
testcase_15 AC 710 ms
139,520 KB
testcase_16 AC 369 ms
104,832 KB
testcase_17 AC 817 ms
142,208 KB
testcase_18 AC 311 ms
96,896 KB
testcase_19 AC 673 ms
138,712 KB
testcase_20 AC 271 ms
93,272 KB
testcase_21 AC 369 ms
102,272 KB
testcase_22 AC 758 ms
132,852 KB
testcase_23 AC 60 ms
70,656 KB
testcase_24 AC 61 ms
71,680 KB
testcase_25 AC 121 ms
85,628 KB
testcase_26 AC 391 ms
108,032 KB
testcase_27 AC 399 ms
109,696 KB
testcase_28 AC 610 ms
129,956 KB
testcase_29 AC 182 ms
83,888 KB
testcase_30 AC 617 ms
134,784 KB
testcase_31 AC 536 ms
119,916 KB
testcase_32 AC 296 ms
102,656 KB
testcase_33 AC 789 ms
139,136 KB
testcase_34 AC 332 ms
98,420 KB
testcase_35 AC 586 ms
137,116 KB
testcase_36 AC 60 ms
68,096 KB
testcase_37 AC 87 ms
77,440 KB
testcase_38 AC 75 ms
71,168 KB
testcase_39 AC 81 ms
73,728 KB
testcase_40 AC 51 ms
62,592 KB
testcase_41 AC 891 ms
142,028 KB
testcase_42 AC 333 ms
98,100 KB
testcase_43 AC 416 ms
111,440 KB
testcase_44 AC 207 ms
89,984 KB
testcase_45 AC 492 ms
111,488 KB
testcase_46 AC 39 ms
52,736 KB
testcase_47 AC 39 ms
53,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
dij = [(0, 1), (1, 0), (1, 1), (1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from heapq import *

def Dist(u, v):
    x0, y0 = xy[u]
    x1, y1 = xy[v]
    return ((x1-x0)**2+(y1-y0)**2)**0.5

n, m = LI()
su, gu = LI1()
xy = LLI(n)
to = [[] for _ in range(n)]
for _ in range(m):
    u, v = LI1()
    d = Dist(u, v)
    to[u].append((v, d))
    to[v].append((u, d))

dist = [inf]*n
dist[su] = 0
hp = [(0, su)]
while hp:
    d, u = heappop(hp)
    if u == gu:
        print(d)
        break
    if d > dist[u]: continue
    for v, c in to[u]:
        nd = d+c
        if nd >= dist[v]: continue
        dist[v] = nd
        heappush(hp, (nd, v))
0