結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー NagisaNagisa
提出日時 2020-05-29 22:39:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,539 ms / 2,000 ms
コード長 1,013 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 124,928 KB
最終ジャッジ日時 2024-04-24 00:02:02
合計ジャッジ時間 30,387 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 754 ms
67,328 KB
testcase_03 AC 1,092 ms
110,136 KB
testcase_04 AC 1,080 ms
109,356 KB
testcase_05 AC 930 ms
102,080 KB
testcase_06 AC 918 ms
101,964 KB
testcase_07 AC 273 ms
41,088 KB
testcase_08 AC 914 ms
124,928 KB
testcase_09 AC 94 ms
20,608 KB
testcase_10 AC 397 ms
61,568 KB
testcase_11 AC 291 ms
45,568 KB
testcase_12 AC 281 ms
34,560 KB
testcase_13 AC 937 ms
75,136 KB
testcase_14 AC 1,046 ms
84,992 KB
testcase_15 AC 1,226 ms
97,280 KB
testcase_16 AC 630 ms
53,888 KB
testcase_17 AC 1,361 ms
103,796 KB
testcase_18 AC 456 ms
42,240 KB
testcase_19 AC 1,213 ms
98,176 KB
testcase_20 AC 311 ms
35,840 KB
testcase_21 AC 555 ms
49,408 KB
testcase_22 AC 1,141 ms
91,648 KB
testcase_23 AC 37 ms
11,776 KB
testcase_24 AC 41 ms
12,032 KB
testcase_25 AC 254 ms
32,000 KB
testcase_26 AC 640 ms
58,996 KB
testcase_27 AC 685 ms
60,416 KB
testcase_28 AC 1,160 ms
91,056 KB
testcase_29 AC 161 ms
22,400 KB
testcase_30 AC 1,225 ms
97,152 KB
testcase_31 AC 820 ms
72,824 KB
testcase_32 AC 524 ms
51,968 KB
testcase_33 AC 1,243 ms
97,664 KB
testcase_34 AC 442 ms
44,032 KB
testcase_35 AC 1,231 ms
98,304 KB
testcase_36 AC 35 ms
11,520 KB
testcase_37 AC 39 ms
11,904 KB
testcase_38 AC 35 ms
11,648 KB
testcase_39 AC 36 ms
11,904 KB
testcase_40 AC 31 ms
11,136 KB
testcase_41 AC 1,539 ms
124,288 KB
testcase_42 AC 441 ms
45,952 KB
testcase_43 AC 781 ms
70,912 KB
testcase_44 AC 262 ms
32,896 KB
testcase_45 AC 738 ms
69,504 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 28 ms
10,880 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