結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー kamojirokamojiro
提出日時 2020-05-29 22:16:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,602 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 112,512 KB
最終ジャッジ日時 2024-04-23 23:00:35
合計ジャッジ時間 33,988 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 751 ms
61,440 KB
testcase_03 AC 1,263 ms
108,544 KB
testcase_04 AC 1,247 ms
107,776 KB
testcase_05 AC 1,006 ms
100,224 KB
testcase_06 AC 1,020 ms
100,224 KB
testcase_07 AC 263 ms
37,632 KB
testcase_08 AC 965 ms
112,512 KB
testcase_09 AC 106 ms
19,456 KB
testcase_10 AC 435 ms
56,064 KB
testcase_11 AC 298 ms
41,856 KB
testcase_12 AC 505 ms
41,472 KB
testcase_13 AC 1,136 ms
76,032 KB
testcase_14 AC 1,181 ms
83,456 KB
testcase_15 AC 1,333 ms
93,952 KB
testcase_16 AC 791 ms
57,728 KB
testcase_17 AC 1,484 ms
99,584 KB
testcase_18 AC 601 ms
46,976 KB
testcase_19 AC 1,291 ms
93,056 KB
testcase_20 AC 355 ms
34,560 KB
testcase_21 AC 818 ms
56,832 KB
testcase_22 AC 1,254 ms
88,448 KB
testcase_23 AC 43 ms
12,032 KB
testcase_24 AC 46 ms
12,160 KB
testcase_25 AC 436 ms
38,016 KB
testcase_26 AC 747 ms
58,172 KB
testcase_27 AC 817 ms
61,056 KB
testcase_28 AC 1,421 ms
93,400 KB
testcase_29 AC 225 ms
24,832 KB
testcase_30 AC 1,602 ms
94,464 KB
testcase_31 AC 853 ms
67,820 KB
testcase_32 AC 558 ms
50,304 KB
testcase_33 AC 1,280 ms
92,288 KB
testcase_34 AC 574 ms
46,592 KB
testcase_35 AC 1,419 ms
95,488 KB
testcase_36 AC 37 ms
11,520 KB
testcase_37 AC 39 ms
11,904 KB
testcase_38 AC 37 ms
11,392 KB
testcase_39 AC 39 ms
11,904 KB
testcase_40 AC 32 ms
11,136 KB
testcase_41 AC 1,495 ms
112,000 KB
testcase_42 AC 426 ms
41,984 KB
testcase_43 AC 746 ms
64,384 KB
testcase_44 AC 249 ms
30,592 KB
testcase_45 AC 744 ms
62,976 KB
testcase_46 AC 30 ms
10,880 KB
testcase_47 AC 29 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

def main():
    N, M = map( int, input().split())
    X, Y = map( int, input().split())
    X -= 1
    Y -= 1
    PQ = [ tuple( map( int, input().split())) for _ in range(N)]
    E = [[] for _ in range(N)]
    for _ in range(M):
        p, q = map( lambda x: int(x)-1, input().split())
        E[p].append((q, ((PQ[p][0]-PQ[q][0])**2 + (PQ[p][1]-PQ[q][1])**2)**(1/2)))
        E[q].append((p, ((PQ[p][0]-PQ[q][0])**2 + (PQ[p][1]-PQ[q][1])**2)**(1/2)))
    h = [(0,X)]
    V = [-1 for _ in range(N)]
    # W = [False for _ in range(N)]
    # V[X] = 0
    # W[X] = True

    while h:
        d, v = heappop(h)
        if V[v] == -1:
            V[v] = d
        else:
            continue
        for w, e in E[v]:
            if V[w] == -1:
                heappush(h, (d+e, w))
        # print(h)
    print(V[Y])
if __name__ == '__main__':
    main()
0