結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー paruf4paruf4
提出日時 2020-05-29 22:39:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,397 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 158,384 KB
最終ジャッジ日時 2024-04-24 00:03:20
合計ジャッジ時間 28,323 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,120 KB
testcase_01 AC 46 ms
52,864 KB
testcase_02 AC 693 ms
116,992 KB
testcase_03 AC 1,031 ms
158,384 KB
testcase_04 AC 1,004 ms
156,340 KB
testcase_05 AC 704 ms
156,668 KB
testcase_06 AC 710 ms
156,920 KB
testcase_07 AC 145 ms
92,928 KB
testcase_08 AC 377 ms
151,040 KB
testcase_09 AC 102 ms
82,816 KB
testcase_10 AC 207 ms
108,896 KB
testcase_11 AC 161 ms
98,432 KB
testcase_12 AC 140 ms
91,136 KB
testcase_13 AC 910 ms
131,232 KB
testcase_14 AC 1,039 ms
138,232 KB
testcase_15 AC 1,219 ms
149,296 KB
testcase_16 AC 621 ms
113,792 KB
testcase_17 AC 1,315 ms
155,344 KB
testcase_18 AC 412 ms
102,612 KB
testcase_19 AC 1,177 ms
149,660 KB
testcase_20 AC 351 ms
96,044 KB
testcase_21 AC 468 ms
109,004 KB
testcase_22 AC 1,166 ms
143,020 KB
testcase_23 AC 56 ms
66,560 KB
testcase_24 AC 62 ms
70,144 KB
testcase_25 AC 141 ms
91,300 KB
testcase_26 AC 632 ms
116,372 KB
testcase_27 AC 688 ms
116,996 KB
testcase_28 AC 1,189 ms
145,456 KB
testcase_29 AC 179 ms
86,128 KB
testcase_30 AC 1,242 ms
148,976 KB
testcase_31 AC 813 ms
127,856 KB
testcase_32 AC 568 ms
110,116 KB
testcase_33 AC 1,397 ms
149,276 KB
testcase_34 AC 465 ms
103,680 KB
testcase_35 AC 1,188 ms
150,704 KB
testcase_36 AC 71 ms
70,784 KB
testcase_37 AC 103 ms
77,440 KB
testcase_38 AC 75 ms
72,192 KB
testcase_39 AC 105 ms
77,636 KB
testcase_40 AC 52 ms
61,824 KB
testcase_41 AC 1,196 ms
150,400 KB
testcase_42 AC 407 ms
100,480 KB
testcase_43 AC 650 ms
115,828 KB
testcase_44 AC 284 ms
91,392 KB
testcase_45 AC 638 ms
115,348 KB
testcase_46 AC 41 ms
52,864 KB
testcase_47 AC 43 ms
52,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
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