結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー naru_1017naru_1017
提出日時 2020-05-29 22:43:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,436 ms / 2,000 ms
コード長 997 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 107,776 KB
最終ジャッジ日時 2024-04-24 00:11:01
合計ジャッジ時間 31,594 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 716 ms
58,880 KB
testcase_03 AC 1,189 ms
100,224 KB
testcase_04 AC 1,170 ms
100,224 KB
testcase_05 AC 895 ms
92,928 KB
testcase_06 AC 917 ms
92,928 KB
testcase_07 AC 230 ms
36,480 KB
testcase_08 AC 787 ms
107,776 KB
testcase_09 AC 90 ms
19,072 KB
testcase_10 AC 369 ms
54,016 KB
testcase_11 AC 257 ms
40,320 KB
testcase_12 AC 410 ms
38,400 KB
testcase_13 AC 1,036 ms
71,936 KB
testcase_14 AC 1,089 ms
79,104 KB
testcase_15 AC 1,246 ms
89,216 KB
testcase_16 AC 720 ms
53,888 KB
testcase_17 AC 1,398 ms
94,336 KB
testcase_18 AC 549 ms
44,032 KB
testcase_19 AC 1,248 ms
88,320 KB
testcase_20 AC 335 ms
33,280 KB
testcase_21 AC 756 ms
52,736 KB
testcase_22 AC 1,257 ms
84,224 KB
testcase_23 AC 41 ms
11,904 KB
testcase_24 AC 48 ms
12,032 KB
testcase_25 AC 375 ms
35,456 KB
testcase_26 AC 699 ms
55,244 KB
testcase_27 AC 802 ms
57,600 KB
testcase_28 AC 1,280 ms
88,004 KB
testcase_29 AC 197 ms
23,936 KB
testcase_30 AC 1,225 ms
89,688 KB
testcase_31 AC 770 ms
64,864 KB
testcase_32 AC 554 ms
47,872 KB
testcase_33 AC 1,179 ms
88,064 KB
testcase_34 AC 540 ms
44,032 KB
testcase_35 AC 1,316 ms
90,440 KB
testcase_36 AC 36 ms
11,264 KB
testcase_37 AC 39 ms
11,776 KB
testcase_38 AC 36 ms
11,392 KB
testcase_39 AC 39 ms
11,776 KB
testcase_40 AC 31 ms
11,264 KB
testcase_41 AC 1,436 ms
107,520 KB
testcase_42 AC 401 ms
40,448 KB
testcase_43 AC 717 ms
62,080 KB
testcase_44 AC 239 ms
29,696 KB
testcase_45 AC 701 ms
60,928 KB
testcase_46 AC 28 ms
10,880 KB
testcase_47 AC 29 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

import heapq

INF=2<<28

def dijkstra(G,start,n):#グラフ,初期頂点,頂点数

    dist=[INF]*n;dist[start]=0
    used=[False]*n;used[start]=True
    q=[]

    for v in G[start]:
        heapq.heappush(q,v)
    
    while len(q)>0:
        now=heapq.heappop(q)
        if used[now[1]]:
            continue
        v=now[1]
        dist[v]=now[0]
        used[v]=True

        for e in G[v]:
            if not used[e[1]]:
                heapq.heappush(q,(e[0]+dist[v],e[1]))

    return dist
def main():
    n,m=map(int,input().split())
    x,y=map(int,input().split())
    x,y=x-1,y-1
    l=[tuple(int(i) for i in input().split()) for _ in range(n)]
    g=[[] for _ in range(n)]
    for _ in range(m):
        p,q=map(int,input().split())
        p,q=p-1,q-1
        dis=((l[q][0]-l[p][0])**2+(l[q][1]-l[p][1])**2)**0.5
        g[p].append((dis,q))
        g[q].append((dis,p))
    a=dijkstra(g,x,n)
    print(a[y])

if __name__=="__main__":
    main()
0