結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー kamojirokamojiro
提出日時 2020-05-29 22:18:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,382 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 110,156 KB
最終ジャッジ日時 2023-08-06 02:31:34
合計ジャッジ時間 30,673 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,212 KB
testcase_01 AC 14 ms
8,060 KB
testcase_02 AC 652 ms
58,768 KB
testcase_03 AC 1,138 ms
106,052 KB
testcase_04 AC 1,092 ms
105,408 KB
testcase_05 AC 819 ms
97,664 KB
testcase_06 AC 814 ms
97,616 KB
testcase_07 AC 204 ms
35,396 KB
testcase_08 AC 749 ms
110,156 KB
testcase_09 AC 74 ms
17,360 KB
testcase_10 AC 342 ms
53,636 KB
testcase_11 AC 232 ms
39,320 KB
testcase_12 AC 415 ms
39,232 KB
testcase_13 AC 1,004 ms
74,216 KB
testcase_14 AC 1,050 ms
81,120 KB
testcase_15 AC 1,229 ms
91,656 KB
testcase_16 AC 729 ms
55,312 KB
testcase_17 AC 1,382 ms
97,392 KB
testcase_18 AC 524 ms
44,508 KB
testcase_19 AC 1,145 ms
90,432 KB
testcase_20 AC 293 ms
32,432 KB
testcase_21 AC 726 ms
54,536 KB
testcase_22 AC 1,165 ms
86,284 KB
testcase_23 AC 27 ms
9,572 KB
testcase_24 AC 31 ms
10,092 KB
testcase_25 AC 371 ms
35,788 KB
testcase_26 AC 636 ms
55,832 KB
testcase_27 AC 728 ms
58,764 KB
testcase_28 AC 1,302 ms
91,068 KB
testcase_29 AC 194 ms
22,728 KB
testcase_30 AC 1,228 ms
92,380 KB
testcase_31 AC 741 ms
65,492 KB
testcase_32 AC 500 ms
47,656 KB
testcase_33 AC 1,148 ms
89,956 KB
testcase_34 AC 510 ms
44,160 KB
testcase_35 AC 1,325 ms
93,004 KB
testcase_36 AC 22 ms
9,040 KB
testcase_37 AC 25 ms
9,612 KB
testcase_38 AC 22 ms
9,120 KB
testcase_39 AC 23 ms
9,552 KB
testcase_40 AC 17 ms
8,712 KB
testcase_41 AC 1,308 ms
109,616 KB
testcase_42 AC 360 ms
39,756 KB
testcase_43 AC 662 ms
62,052 KB
testcase_44 AC 224 ms
28,096 KB
testcase_45 AC 633 ms
60,752 KB
testcase_46 AC 15 ms
8,216 KB
testcase_47 AC 15 ms
8,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappop, heappush

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