結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー O2MTO2MT
提出日時 2020-08-31 14:21:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 112,640 KB
最終ジャッジ日時 2024-04-27 18:14:36
合計ジャッジ時間 48,112 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 AC 28 ms
11,008 KB
testcase_02 AC 1,167 ms
61,312 KB
testcase_03 AC 1,709 ms
99,748 KB
testcase_04 AC 1,745 ms
99,088 KB
testcase_05 AC 1,607 ms
91,648 KB
testcase_06 AC 1,559 ms
91,520 KB
testcase_07 AC 464 ms
37,760 KB
testcase_08 AC 1,737 ms
112,640 KB
testcase_09 AC 158 ms
19,712 KB
testcase_10 AC 753 ms
56,320 KB
testcase_11 AC 524 ms
41,984 KB
testcase_12 AC 452 ms
31,360 KB
testcase_13 AC 1,344 ms
67,712 KB
testcase_14 AC 1,550 ms
77,056 KB
testcase_15 AC 1,838 ms
88,320 KB
testcase_16 AC 893 ms
49,024 KB
testcase_17 AC 1,982 ms
94,208 KB
testcase_18 AC 624 ms
38,784 KB
testcase_19 AC 1,914 ms
88,832 KB
testcase_20 AC 516 ms
33,408 KB
testcase_21 AC 862 ms
44,672 KB
testcase_22 AC 1,738 ms
82,816 KB
testcase_23 AC 45 ms
11,776 KB
testcase_24 AC 49 ms
12,032 KB
testcase_25 AC 423 ms
29,056 KB
testcase_26 AC 1,020 ms
53,824 KB
testcase_27 AC 1,094 ms
54,784 KB
testcase_28 AC 1,770 ms
82,396 KB
testcase_29 AC 251 ms
20,992 KB
testcase_30 AC 1,876 ms
87,936 KB
testcase_31 AC 1,310 ms
66,764 KB
testcase_32 AC 835 ms
47,744 KB
testcase_33 AC 1,861 ms
89,072 KB
testcase_34 AC 691 ms
40,192 KB
testcase_35 AC 1,904 ms
89,276 KB
testcase_36 AC 37 ms
11,392 KB
testcase_37 AC 46 ms
11,904 KB
testcase_38 AC 40 ms
11,520 KB
testcase_39 AC 44 ms
11,904 KB
testcase_40 AC 33 ms
11,136 KB
testcase_41 TLE -
testcase_42 AC 672 ms
42,368 KB
testcase_43 AC 1,211 ms
64,512 KB
testcase_44 AC 549 ms
30,592 KB
testcase_45 AC 1,173 ms
63,232 KB
testcase_46 AC 27 ms
11,008 KB
testcase_47 AC 26 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
import heapq

def dijkstra(s, h, graph):
    n = len(graph)-1
    dist = [float("inf") for i in range(n+1)]
    dist[s] = 0
    pq = []
    heapq.heapify(pq)
    heapq.heappush(pq, (0, s))
    while pq:
        mini_dis, node = heapq.heappop(pq)
        if dist[node] < mini_dis:
            continue
        for w, point in graph[node]:
            if dist[point] < w:
                continue
            newlen = dist[node]+w
            if newlen < dist[point]:
                heapq.heappush(pq, (newlen, point))
                dist[point] = newlen
    return dist

N,M = map(int,input().split())
X,Y = map(int,input().split())
l = [[] for _ in range(N+1)] 
d =  [[] for _ in range(N+1)] 
for i in range(1,N+1):
  a,b = map(int,input().split())
  d[i].append(a)
  d[i].append(b)

for _ in range(M):
  a,b = map(int,input().split())
  dist = sqrt((d[a][0]-d[b][0])**2 + (d[a][1]-d[b][1])**2)
  l[a].append((dist,b))
  l[b].append((dist,a))
  
ans = dijkstra(X, Y, l)

print(ans[Y])
0