結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー naru_1017naru_1017
提出日時 2020-05-29 22:36:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,922 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 107,648 KB
最終ジャッジ日時 2024-04-23 23:51:31
合計ジャッジ時間 43,303 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 974 ms
59,008 KB
testcase_03 AC 1,680 ms
100,224 KB
testcase_04 AC 1,593 ms
100,352 KB
testcase_05 AC 1,216 ms
93,056 KB
testcase_06 AC 1,193 ms
92,928 KB
testcase_07 AC 314 ms
36,608 KB
testcase_08 AC 1,083 ms
107,648 KB
testcase_09 AC 118 ms
19,072 KB
testcase_10 AC 498 ms
53,888 KB
testcase_11 AC 353 ms
40,320 KB
testcase_12 AC 575 ms
38,272 KB
testcase_13 AC 1,410 ms
71,808 KB
testcase_14 AC 1,523 ms
79,232 KB
testcase_15 AC 1,712 ms
89,216 KB
testcase_16 AC 961 ms
54,144 KB
testcase_17 AC 1,922 ms
94,336 KB
testcase_18 AC 715 ms
44,160 KB
testcase_19 AC 1,640 ms
88,448 KB
testcase_20 AC 401 ms
33,280 KB
testcase_21 AC 919 ms
52,736 KB
testcase_22 AC 1,580 ms
84,224 KB
testcase_23 AC 48 ms
11,776 KB
testcase_24 AC 52 ms
12,032 KB
testcase_25 AC 476 ms
35,200 KB
testcase_26 AC 874 ms
55,352 KB
testcase_27 AC 1,020 ms
57,600 KB
testcase_28 AC 1,831 ms
87,936 KB
testcase_29 AC 279 ms
23,808 KB
testcase_30 AC 1,758 ms
89,812 KB
testcase_31 AC 1,098 ms
64,720 KB
testcase_32 AC 754 ms
47,988 KB
testcase_33 AC 1,627 ms
88,064 KB
testcase_34 AC 698 ms
44,160 KB
testcase_35 AC 1,731 ms
90,360 KB
testcase_36 AC 40 ms
11,264 KB
testcase_37 AC 44 ms
11,776 KB
testcase_38 AC 41 ms
11,392 KB
testcase_39 AC 44 ms
11,776 KB
testcase_40 AC 35 ms
11,136 KB
testcase_41 AC 1,861 ms
107,264 KB
testcase_42 AC 526 ms
40,320 KB
testcase_43 AC 976 ms
62,080 KB
testcase_44 AC 355 ms
29,568 KB
testcase_45 AC 955 ms
60,672 KB
testcase_46 AC 30 ms
11,008 KB
testcase_47 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)


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

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])
0