結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー hedwig100hedwig100
提出日時 2020-05-29 21:50:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,092 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 118,784 KB
最終ジャッジ日時 2024-04-23 21:32:55
合計ジャッジ時間 42,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 28 ms
11,008 KB
testcase_02 AC 1,061 ms
64,384 KB
testcase_03 AC 1,577 ms
103,844 KB
testcase_04 AC 1,580 ms
103,184 KB
testcase_05 AC 1,432 ms
95,680 KB
testcase_06 AC 1,406 ms
95,680 KB
testcase_07 AC 410 ms
39,424 KB
testcase_08 AC 1,516 ms
118,784 KB
testcase_09 AC 155 ms
20,224 KB
testcase_10 AC 656 ms
58,880 KB
testcase_11 AC 468 ms
43,776 KB
testcase_12 AC 427 ms
31,232 KB
testcase_13 AC 1,245 ms
70,016 KB
testcase_14 AC 1,487 ms
80,128 KB
testcase_15 AC 1,661 ms
91,776 KB
testcase_16 AC 883 ms
50,176 KB
testcase_17 AC 1,840 ms
97,896 KB
testcase_18 AC 627 ms
39,296 KB
testcase_19 AC 1,662 ms
92,800 KB
testcase_20 AC 457 ms
34,176 KB
testcase_21 AC 770 ms
45,056 KB
testcase_22 AC 1,504 ms
86,400 KB
testcase_23 AC 46 ms
11,648 KB
testcase_24 AC 50 ms
11,904 KB
testcase_25 AC 389 ms
29,056 KB
testcase_26 AC 893 ms
55,592 KB
testcase_27 AC 925 ms
56,448 KB
testcase_28 AC 1,579 ms
85,120 KB
testcase_29 AC 224 ms
21,120 KB
testcase_30 AC 1,670 ms
91,544 KB
testcase_31 AC 1,111 ms
69,220 KB
testcase_32 AC 733 ms
49,536 KB
testcase_33 AC 1,647 ms
92,800 KB
testcase_34 AC 642 ms
41,088 KB
testcase_35 TLE -
testcase_36 AC 43 ms
11,264 KB
testcase_37 AC 44 ms
12,032 KB
testcase_38 AC 37 ms
11,392 KB
testcase_39 AC 43 ms
11,776 KB
testcase_40 AC 31 ms
11,008 KB
testcase_41 TLE -
testcase_42 AC 631 ms
43,904 KB
testcase_43 AC 1,082 ms
67,712 KB
testcase_44 AC 383 ms
31,744 KB
testcase_45 AC 1,067 ms
66,304 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 25 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
from heapq import heapify,heappop,heappush

def dijkstra(G,s = 0): #sを始点とした最短経を求める
    n = len(G)
    dist = [INF] * n
    dist[s] = 0
    q = [(0,s)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for e,cost in G[v]:
            if dist[e] > dist[v] + cost:
                dist[e] = dist[v] + cost
                heappush(q,(dist[e],e))
    return dist
def main():
    N,M = map(int,input().split())
    X,Y = map(int,input().split())
    point = [list(map(int,input().split())) for _ in range(N)]
    dist = lambda i,j:((point[i][0] - point[j][0])*(point[i][0] - point[j][0]) + (point[i][1] - point[j][1])*(point[i][1] - point[j][1]))**0.5
    G = [[] for _ in range(N)]
    for _ in range(M):
        x,y = map(int,input().split())
        x -= 1
        y -= 1
        d = dist(x,y)
        G[x].append((y,d))
        G[y].append((x,d))
    dist = dijkstra(G,X - 1)
    ans = dist[Y - 1]
    print(ans)
if __name__ == '__main__':
    main()
0