結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー NagisaNagisa
提出日時 2020-05-29 22:40:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 954 ms / 2,000 ms
コード長 1,013 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 151,588 KB
最終ジャッジ日時 2024-04-24 00:05:31
合計ジャッジ時間 22,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,864 KB
testcase_01 AC 43 ms
53,248 KB
testcase_02 AC 538 ms
113,736 KB
testcase_03 AC 687 ms
146,012 KB
testcase_04 AC 663 ms
145,228 KB
testcase_05 AC 479 ms
147,388 KB
testcase_06 AC 488 ms
146,756 KB
testcase_07 AC 153 ms
92,160 KB
testcase_08 AC 367 ms
150,108 KB
testcase_09 AC 110 ms
82,432 KB
testcase_10 AC 207 ms
107,484 KB
testcase_11 AC 170 ms
96,604 KB
testcase_12 AC 140 ms
88,320 KB
testcase_13 AC 679 ms
121,864 KB
testcase_14 AC 764 ms
127,832 KB
testcase_15 AC 870 ms
139,516 KB
testcase_16 AC 462 ms
104,576 KB
testcase_17 AC 920 ms
143,560 KB
testcase_18 AC 364 ms
97,364 KB
testcase_19 AC 856 ms
140,948 KB
testcase_20 AC 302 ms
92,544 KB
testcase_21 AC 394 ms
101,028 KB
testcase_22 AC 812 ms
133,300 KB
testcase_23 AC 64 ms
65,920 KB
testcase_24 AC 69 ms
69,248 KB
testcase_25 AC 136 ms
88,576 KB
testcase_26 AC 486 ms
110,180 KB
testcase_27 AC 540 ms
109,696 KB
testcase_28 AC 857 ms
132,792 KB
testcase_29 AC 192 ms
83,840 KB
testcase_30 AC 860 ms
138,096 KB
testcase_31 AC 594 ms
120,940 KB
testcase_32 AC 442 ms
104,280 KB
testcase_33 AC 954 ms
139,816 KB
testcase_34 AC 391 ms
98,688 KB
testcase_35 AC 854 ms
139,272 KB
testcase_36 AC 80 ms
70,272 KB
testcase_37 AC 117 ms
77,440 KB
testcase_38 AC 83 ms
71,424 KB
testcase_39 AC 118 ms
77,668 KB
testcase_40 AC 56 ms
61,952 KB
testcase_41 AC 935 ms
151,588 KB
testcase_42 AC 351 ms
98,276 KB
testcase_43 AC 531 ms
115,052 KB
testcase_44 AC 249 ms
91,264 KB
testcase_45 AC 517 ms
113,712 KB
testcase_46 AC 44 ms
52,864 KB
testcase_47 AC 43 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import sqrt
from heapq import heappush, heappop
INF = 10**10
input = sys.stdin.readline
def main():
    N, M = map(int,input().split())
    X, Y = map(int,input().split())
    X -= 1
    Y -= 1
    D = []
    for _ in range(N):
        D.append(list(map(int,input().split())))
    K = [[] for _ in range(N)]
    for _ in range(M):
        P, Q = map(int,input().split())
        P -= 1
        Q -= 1
        K[P].append((Q,sqrt((D[P][0]-D[Q][0])**2+(D[P][1]-D[Q][1])**2)))
        K[Q].append((P,sqrt((D[P][0]-D[Q][0])**2+(D[P][1]-D[Q][1])**2)))
    dist = [INF] * N
    def dijkstra(N, G, s):
        que = [(0, s)]
        dist[s] = 0
        while que:
            c, v = heappop(que)
            if dist[v] < c:
                continue
            for t, cost in G[v]:
                if dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    heappush(que, (dist[t], t))
    dijkstra(N, K, X)
    print(dist[Y])
if __name__ == '__main__':
    main()
0