結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー mkawa2mkawa2
提出日時 2021-05-28 17:42:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,314 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 118,784 KB
最終ジャッジ日時 2024-04-24 21:06:05
合計ジャッジ時間 40,531 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 833 ms
61,824 KB
testcase_03 AC 1,412 ms
103,756 KB
testcase_04 AC 1,581 ms
102,968 KB
testcase_05 AC 1,310 ms
95,572 KB
testcase_06 AC 1,350 ms
95,704 KB
testcase_07 AC 362 ms
39,552 KB
testcase_08 AC 1,407 ms
118,784 KB
testcase_09 AC 137 ms
19,968 KB
testcase_10 AC 617 ms
58,880 KB
testcase_11 AC 427 ms
43,776 KB
testcase_12 AC 339 ms
31,104 KB
testcase_13 AC 1,198 ms
70,144 KB
testcase_14 AC 1,264 ms
80,128 KB
testcase_15 AC 1,560 ms
91,520 KB
testcase_16 AC 761 ms
50,048 KB
testcase_17 AC 1,853 ms
97,656 KB
testcase_18 AC 632 ms
39,168 KB
testcase_19 AC 1,516 ms
92,160 KB
testcase_20 AC 454 ms
34,304 KB
testcase_21 AC 802 ms
44,928 KB
testcase_22 AC 1,500 ms
86,272 KB
testcase_23 AC 46 ms
11,776 KB
testcase_24 AC 48 ms
11,776 KB
testcase_25 AC 311 ms
28,928 KB
testcase_26 AC 748 ms
54,528 KB
testcase_27 AC 787 ms
56,064 KB
testcase_28 AC 1,330 ms
83,712 KB
testcase_29 AC 228 ms
20,992 KB
testcase_30 AC 1,367 ms
90,712 KB
testcase_31 AC 1,138 ms
69,224 KB
testcase_32 AC 563 ms
47,488 KB
testcase_33 AC 1,625 ms
92,652 KB
testcase_34 AC 609 ms
40,960 KB
testcase_35 AC 1,273 ms
90,496 KB
testcase_36 AC 40 ms
11,264 KB
testcase_37 AC 44 ms
11,776 KB
testcase_38 AC 40 ms
11,264 KB
testcase_39 AC 42 ms
11,904 KB
testcase_40 AC 35 ms
11,008 KB
testcase_41 TLE -
testcase_42 AC 589 ms
43,392 KB
testcase_43 AC 935 ms
65,536 KB
testcase_44 AC 299 ms
30,720 KB
testcase_45 AC 1,062 ms
66,176 KB
testcase_46 AC 33 ms
10,880 KB
testcase_47 AC 32 ms
11,008 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