結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー maspymaspy
提出日時 2020-05-29 22:28:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,404 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 103,376 KB
最終ジャッジ日時 2024-04-23 23:28:37
合計ジャッジ時間 28,305 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 714 ms
56,092 KB
testcase_03 AC 1,030 ms
91,912 KB
testcase_04 AC 1,029 ms
91,784 KB
testcase_05 AC 930 ms
91,656 KB
testcase_06 AC 912 ms
91,856 KB
testcase_07 AC 252 ms
35,960 KB
testcase_08 AC 863 ms
103,376 KB
testcase_09 AC 95 ms
18,784 KB
testcase_10 AC 387 ms
51,920 KB
testcase_11 AC 282 ms
39,736 KB
testcase_12 AC 245 ms
41,892 KB
testcase_13 AC 845 ms
63,608 KB
testcase_14 AC 957 ms
65,956 KB
testcase_15 AC 1,159 ms
75,056 KB
testcase_16 AC 554 ms
51,760 KB
testcase_17 AC 1,250 ms
80,640 KB
testcase_18 AC 396 ms
42,592 KB
testcase_19 AC 1,157 ms
77,312 KB
testcase_20 AC 294 ms
30,236 KB
testcase_21 AC 491 ms
53,260 KB
testcase_22 AC 1,056 ms
71,660 KB
testcase_23 AC 36 ms
12,032 KB
testcase_24 AC 38 ms
12,288 KB
testcase_25 AC 219 ms
38,324 KB
testcase_26 AC 566 ms
48,120 KB
testcase_27 AC 612 ms
51,152 KB
testcase_28 AC 1,095 ms
75,364 KB
testcase_29 AC 134 ms
24,260 KB
testcase_30 AC 1,108 ms
74,596 KB
testcase_31 AC 740 ms
55,668 KB
testcase_32 AC 458 ms
41,144 KB
testcase_33 AC 1,124 ms
75,060 KB
testcase_34 AC 388 ms
39,544 KB
testcase_35 AC 1,138 ms
77,144 KB
testcase_36 AC 33 ms
11,392 KB
testcase_37 AC 35 ms
11,776 KB
testcase_38 AC 32 ms
11,392 KB
testcase_39 AC 34 ms
11,776 KB
testcase_40 AC 28 ms
11,136 KB
testcase_41 AC 1,404 ms
102,664 KB
testcase_42 AC 400 ms
39,776 KB
testcase_43 AC 697 ms
59,344 KB
testcase_44 AC 240 ms
28,628 KB
testcase_45 AC 688 ms
58,164 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 28 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from heapq import heappop, heappush

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
S, T = map(int, readline().split())
X = [complex(0, 0)] * (N + 1)
for i in range(1, N + 1):
    p, q = map(int, readline().split())
    X[i] = complex(p, q)
G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for p, q in zip(m, m):
    d = abs(X[p] - X[q])
    G[p].append((q, d))
    G[q].append((p, d))

INF = 10.0**18
dist = [INF] * (N+1)
q = [(0, S)]
dist[S] = 0
while q:
    dv, v = heappop(q)
    if dv != dist[v]:
        continue
    for w, d in G[v]:
        dw = dv + d
        if dist[w] > dw:
            dist[w] = dw
            heappush(q, (dw, w))

print(dist[T])
0