結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pluto77pluto77
提出日時 2020-06-19 13:14:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,367 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 160,552 KB
最終ジャッジ日時 2023-09-16 12:46:58
合計ジャッジ時間 31,179 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,760 KB
testcase_01 AC 73 ms
71,524 KB
testcase_02 AC 749 ms
118,920 KB
testcase_03 AC 1,049 ms
160,552 KB
testcase_04 AC 1,134 ms
159,184 KB
testcase_05 AC 840 ms
158,152 KB
testcase_06 AC 821 ms
158,228 KB
testcase_07 AC 228 ms
96,528 KB
testcase_08 AC 511 ms
153,492 KB
testcase_09 AC 165 ms
85,036 KB
testcase_10 AC 298 ms
111,804 KB
testcase_11 AC 243 ms
100,772 KB
testcase_12 AC 213 ms
97,848 KB
testcase_13 AC 875 ms
133,916 KB
testcase_14 AC 977 ms
140,800 KB
testcase_15 AC 1,157 ms
151,176 KB
testcase_16 AC 643 ms
116,120 KB
testcase_17 AC 1,367 ms
158,304 KB
testcase_18 AC 494 ms
105,476 KB
testcase_19 AC 1,201 ms
152,988 KB
testcase_20 AC 407 ms
99,912 KB
testcase_21 AC 531 ms
112,464 KB
testcase_22 AC 1,144 ms
146,764 KB
testcase_23 AC 105 ms
78,028 KB
testcase_24 AC 113 ms
78,484 KB
testcase_25 AC 200 ms
92,848 KB
testcase_26 AC 652 ms
119,424 KB
testcase_27 AC 718 ms
120,920 KB
testcase_28 AC 1,252 ms
148,660 KB
testcase_29 AC 256 ms
88,012 KB
testcase_30 AC 1,246 ms
151,456 KB
testcase_31 AC 849 ms
129,932 KB
testcase_32 AC 595 ms
112,316 KB
testcase_33 AC 1,342 ms
152,708 KB
testcase_34 AC 484 ms
105,964 KB
testcase_35 AC 1,127 ms
153,892 KB
testcase_36 AC 116 ms
78,948 KB
testcase_37 AC 162 ms
79,496 KB
testcase_38 AC 126 ms
78,868 KB
testcase_39 AC 161 ms
79,784 KB
testcase_40 AC 92 ms
76,556 KB
testcase_41 AC 1,265 ms
154,356 KB
testcase_42 AC 462 ms
102,220 KB
testcase_43 AC 708 ms
119,812 KB
testcase_44 AC 335 ms
93,728 KB
testcase_45 AC 692 ms
117,652 KB
testcase_46 AC 75 ms
71,432 KB
testcase_47 AC 72 ms
71,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1065
from heapq import heappop,heappush

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=((pq[q][0]-pq[p][0])**2+(pq[q][1]-pq[p][1])**2)**0.5
 G[p].append([q,c])
 G[q].append([p,c])
d=dijkstra(x-1,n,G)
print(d[y-1])
0