結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー tktk_snsntktk_snsn
提出日時 2020-05-29 22:03:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,688 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 106,488 KB
最終ジャッジ日時 2024-04-23 22:30:51
合計ジャッジ時間 23,501 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
11,136 KB
testcase_01 AC 28 ms
11,008 KB
testcase_02 AC 825 ms
58,240 KB
testcase_03 AC 1,210 ms
98,268 KB
testcase_04 AC 1,201 ms
96,768 KB
testcase_05 AC 1,071 ms
89,376 KB
testcase_06 AC 1,070 ms
89,376 KB
testcase_07 AC 275 ms
36,096 KB
testcase_08 AC 950 ms
106,488 KB
testcase_09 AC 108 ms
19,072 KB
testcase_10 AC 439 ms
53,376 KB
testcase_11 AC 318 ms
39,936 KB
testcase_12 AC 301 ms
31,360 KB
testcase_13 AC 1,009 ms
67,456 KB
testcase_14 AC 1,108 ms
76,160 KB
testcase_15 AC 1,323 ms
87,552 KB
testcase_16 AC 641 ms
48,768 KB
testcase_17 AC 1,451 ms
92,288 KB
testcase_18 AC 461 ms
38,528 KB
testcase_19 AC 1,293 ms
86,656 KB
testcase_20 AC 328 ms
32,640 KB
testcase_21 AC 579 ms
44,416 KB
testcase_22 AC 1,288 ms
82,048 KB
testcase_23 AC 38 ms
11,904 KB
testcase_24 AC 41 ms
11,904 KB
testcase_25 AC 272 ms
29,184 KB
testcase_26 AC 695 ms
52,636 KB
testcase_27 AC 737 ms
54,272 KB
testcase_28 AC 1,256 ms
81,280 KB
testcase_29 AC 169 ms
20,992 KB
testcase_30 AC 1,315 ms
86,468 KB
testcase_31 AC 905 ms
65,024 KB
testcase_32 AC 567 ms
47,212 KB
testcase_33 AC 1,354 ms
89,020 KB
testcase_34 AC 486 ms
40,192 KB
testcase_35 AC 1,357 ms
87,792 KB
testcase_36 AC 33 ms
11,392 KB
testcase_37 AC 37 ms
11,904 KB
testcase_38 AC 35 ms
11,520 KB
testcase_39 AC 38 ms
12,032 KB
testcase_40 AC 32 ms
11,136 KB
testcase_41 AC 1,688 ms
105,908 KB
testcase_42 AC 464 ms
40,320 KB
testcase_43 AC 825 ms
61,312 KB
testcase_44 AC 294 ms
29,440 KB
testcase_45 AC 805 ms
60,032 KB
testcase_46 AC 27 ms
11,008 KB
testcase_47 AC 26 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import math
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
S, T = map(int, input().split())
xy = tuple(tuple(map(int, input().split())) for _ in range(N))
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    p, q = map(int, input().split())
    x1, y1 = xy[p - 1]
    x2, y2 = xy[q - 1]
    d = math.hypot(x1 - x2, y1 - y2)
    edge[p].append((q, d))
    edge[q].append((p, d))

inf = 10**18
dist = [inf] * (N + 1)
dist[S] = 0
que = [(0, S)]
while que:
    c, s = heapq.heappop(que)
    if dist[s] < c:
        continue
    cost = dist[s]
    for t, d in edge[s]:
        if dist[t] > cost + d:
            dist[t] = cost + d
            heapq.heappush(que, (cost+d, t))

print(dist[T])
0