結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー takakintakakin
提出日時 2020-06-04 00:02:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,664 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-05-04 20:14:40
合計ジャッジ時間 33,098 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 730 ms
46,208 KB
testcase_03 AC 1,197 ms
69,376 KB
testcase_04 AC 1,181 ms
70,912 KB
testcase_05 AC 976 ms
59,520 KB
testcase_06 AC 1,045 ms
59,648 KB
testcase_07 AC 344 ms
29,952 KB
testcase_08 AC 1,226 ms
82,688 KB
testcase_09 AC 119 ms
17,024 KB
testcase_10 AC 515 ms
42,880 KB
testcase_11 AC 382 ms
32,768 KB
testcase_12 AC 450 ms
24,320 KB
testcase_13 AC 1,013 ms
49,024 KB
testcase_14 AC 1,071 ms
55,936 KB
testcase_15 AC 1,207 ms
62,720 KB
testcase_16 AC 685 ms
35,712 KB
testcase_17 AC 1,376 ms
66,944 KB
testcase_18 AC 531 ms
29,824 KB
testcase_19 AC 1,226 ms
64,768 KB
testcase_20 AC 353 ms
26,112 KB
testcase_21 AC 696 ms
33,536 KB
testcase_22 AC 1,189 ms
58,624 KB
testcase_23 AC 45 ms
11,520 KB
testcase_24 AC 45 ms
11,776 KB
testcase_25 AC 390 ms
23,040 KB
testcase_26 AC 704 ms
40,776 KB
testcase_27 AC 782 ms
40,064 KB
testcase_28 AC 1,291 ms
58,748 KB
testcase_29 AC 215 ms
17,664 KB
testcase_30 AC 1,260 ms
63,872 KB
testcase_31 AC 837 ms
49,692 KB
testcase_32 AC 548 ms
36,352 KB
testcase_33 AC 1,147 ms
62,592 KB
testcase_34 AC 524 ms
30,336 KB
testcase_35 AC 1,298 ms
64,388 KB
testcase_36 AC 35 ms
11,136 KB
testcase_37 AC 40 ms
11,648 KB
testcase_38 AC 35 ms
11,392 KB
testcase_39 AC 39 ms
11,520 KB
testcase_40 AC 31 ms
11,008 KB
testcase_41 AC 1,664 ms
82,560 KB
testcase_42 AC 481 ms
32,896 KB
testcase_43 AC 803 ms
48,896 KB
testcase_44 AC 282 ms
24,832 KB
testcase_45 AC 779 ms
47,872 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
x,y=map(int,input().split())
PQ=[tuple(int(i) for i in input().split()) for _ in range(n)]

def f(A,B):
  a1,a2=A
  b1,b2=B
  return int((((a1-b1)**2+(a2-b2)**2)**0.5)*10**9)

edge=[[] for i in range(n)]
for _ in range(m):
  p,q=map(int,input().split())
  dis=f(PQ[p-1],PQ[q-1])
  edge[p-1].append(dis*10**6+q-1)
  edge[q-1].append(dis*10**6+p-1)

import heapq
def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge=heapq.heappop(edgelist)
    minedge_cost=minedge//(10**6)
    minedge_v=minedge%(10**6)
    if not used[minedge_v]:
      continue
    d[minedge_v] = minedge_cost
    used[minedge_v] = False
    for e in edge[minedge_v]:
      e_cost=e//(10**6)
      e_v=e%(10**6)
      if used[e_v]:
        heapq.heappush(edgelist,e+minedge_cost*10**6)
  return d
print(dijkstra_heap(x-1)[y-1]/(10**9))
0