結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 579 ms
58,752 KB
testcase_03 AC 1,105 ms
108,544 KB
testcase_04 AC 1,243 ms
107,776 KB
testcase_05 AC 996 ms
100,352 KB
testcase_06 AC 1,007 ms
100,224 KB
testcase_07 AC 261 ms
37,632 KB
testcase_08 AC 929 ms
112,384 KB
testcase_09 AC 99 ms
19,456 KB
testcase_10 AC 404 ms
55,936 KB
testcase_11 AC 286 ms
41,984 KB
testcase_12 AC 300 ms
37,120 KB
testcase_13 AC 923 ms
75,904 KB
testcase_14 AC 923 ms
83,456 KB
testcase_15 AC 1,147 ms
93,696 KB
testcase_16 AC 617 ms
57,344 KB
testcase_17 AC 1,322 ms
99,712 KB
testcase_18 AC 495 ms
47,232 KB
testcase_19 AC 1,038 ms
92,032 KB
testcase_20 AC 337 ms
34,560 KB
testcase_21 AC 668 ms
56,832 KB
testcase_22 AC 1,083 ms
88,704 KB
testcase_23 AC 41 ms
12,160 KB
testcase_24 AC 40 ms
12,160 KB
testcase_25 AC 275 ms
34,560 KB
testcase_26 AC 527 ms
54,272 KB
testcase_27 AC 588 ms
59,008 KB
testcase_28 AC 976 ms
88,616 KB
testcase_29 AC 200 ms
25,088 KB
testcase_30 AC 927 ms
91,136 KB
testcase_31 AC 770 ms
67,820 KB
testcase_32 AC 408 ms
46,592 KB
testcase_33 AC 1,111 ms
92,160 KB
testcase_34 AC 479 ms
46,848 KB
testcase_35 AC 1,033 ms
89,324 KB
testcase_36 AC 38 ms
11,392 KB
testcase_37 AC 40 ms
11,648 KB
testcase_38 AC 32 ms
11,520 KB
testcase_39 AC 35 ms
11,648 KB
testcase_40 AC 30 ms
11,008 KB
testcase_41 AC 1,419 ms
110,848 KB
testcase_42 AC 400 ms
41,344 KB
testcase_43 AC 621 ms
62,208 KB
testcase_44 AC 200 ms
29,440 KB
testcase_45 AC 719 ms
62,976 KB
testcase_46 AC 26 ms
11,008 KB
testcase_47 AC 26 ms
10,880 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)]
    while h:
        d, v = heappop(h)
        if V[v] == -1:
            V[v] = d
            if v == Y:
                break
        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