結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pluto77pluto77
提出日時 2020-06-19 13:34:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,285 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 160,024 KB
最終ジャッジ日時 2023-09-16 12:49:24
合計ジャッジ時間 31,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,256 KB
testcase_01 AC 74 ms
71,208 KB
testcase_02 AC 716 ms
118,844 KB
testcase_03 AC 1,048 ms
160,024 KB
testcase_04 AC 1,026 ms
158,768 KB
testcase_05 AC 823 ms
158,676 KB
testcase_06 AC 827 ms
158,972 KB
testcase_07 AC 225 ms
96,328 KB
testcase_08 AC 502 ms
153,208 KB
testcase_09 AC 162 ms
85,048 KB
testcase_10 AC 299 ms
111,480 KB
testcase_11 AC 243 ms
100,364 KB
testcase_12 AC 208 ms
97,276 KB
testcase_13 AC 913 ms
134,260 KB
testcase_14 AC 1,001 ms
140,756 KB
testcase_15 AC 1,166 ms
150,932 KB
testcase_16 AC 621 ms
115,680 KB
testcase_17 AC 1,256 ms
157,740 KB
testcase_18 AC 452 ms
105,316 KB
testcase_19 AC 1,159 ms
153,100 KB
testcase_20 AC 411 ms
99,356 KB
testcase_21 AC 518 ms
112,204 KB
testcase_22 AC 1,102 ms
146,384 KB
testcase_23 AC 104 ms
77,948 KB
testcase_24 AC 106 ms
78,044 KB
testcase_25 AC 193 ms
92,616 KB
testcase_26 AC 619 ms
119,244 KB
testcase_27 AC 678 ms
120,244 KB
testcase_28 AC 1,137 ms
148,420 KB
testcase_29 AC 240 ms
87,744 KB
testcase_30 AC 1,143 ms
151,184 KB
testcase_31 AC 819 ms
129,496 KB
testcase_32 AC 574 ms
112,188 KB
testcase_33 AC 1,285 ms
152,112 KB
testcase_34 AC 476 ms
105,824 KB
testcase_35 AC 1,145 ms
154,180 KB
testcase_36 AC 120 ms
79,040 KB
testcase_37 AC 163 ms
79,368 KB
testcase_38 AC 127 ms
78,960 KB
testcase_39 AC 160 ms
79,452 KB
testcase_40 AC 92 ms
76,256 KB
testcase_41 AC 1,219 ms
154,476 KB
testcase_42 AC 460 ms
101,476 KB
testcase_43 AC 715 ms
119,524 KB
testcase_44 AC 343 ms
93,256 KB
testcase_45 AC 683 ms
117,320 KB
testcase_46 AC 75 ms
71,444 KB
testcase_47 AC 73 ms
71,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1065
from heapq import heappop,heappush
import math

def dijkstra(s,n,edge):
 dist=[float("inf")]*n
 dist[s]=0
 used=[-1]*n
 hq=[[dist[s],s]]
 while hq:
  d,cur=heappop(hq)
  if dist[cur]<d:
   continue
  for nx,nxd in edge[cur]:
   if dist[cur]+nxd<dist[nx]:
    dist[nx]=dist[cur]+nxd
    used[nx]=cur
    heappush(hq,[dist[cur]+nxd,nx])
 return dist
  
n,m=map(int,input().split())
x,y=map(int,input().split())
pq=[tuple(map(int,input().split())) for i in range(n)]
G=[[] for i in range(n)]
for i in range(m):
 p,q=map(int,input().split())
 p-=1
 q-=1
 c=math.sqrt((pq[q][0]-pq[p][0])**2+(pq[q][1]-pq[p][1])**2)
 G[p].append([q,c])
 G[q].append([p,c])
d=dijkstra(x-1,n,G)
print(d[y-1])
0