結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー paruf4paruf4
提出日時 2020-05-29 22:37:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,530 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 158,984 KB
最終ジャッジ日時 2024-11-06 06:22:23
合計ジャッジ時間 33,212 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,840 KB
testcase_01 AC 43 ms
53,600 KB
testcase_02 AC 802 ms
117,864 KB
testcase_03 AC 1,130 ms
158,984 KB
testcase_04 AC 1,126 ms
157,996 KB
testcase_05 AC 848 ms
158,184 KB
testcase_06 AC 857 ms
158,176 KB
testcase_07 AC 218 ms
96,996 KB
testcase_08 AC 517 ms
151,452 KB
testcase_09 AC 144 ms
84,220 KB
testcase_10 AC 294 ms
110,384 KB
testcase_11 AC 235 ms
99,624 KB
testcase_12 AC 197 ms
95,764 KB
testcase_13 AC 1,008 ms
133,004 KB
testcase_14 AC 1,144 ms
139,252 KB
testcase_15 AC 1,351 ms
150,376 KB
testcase_16 AC 682 ms
113,924 KB
testcase_17 AC 1,476 ms
156,668 KB
testcase_18 AC 487 ms
104,104 KB
testcase_19 AC 1,304 ms
152,804 KB
testcase_20 AC 403 ms
97,328 KB
testcase_21 AC 526 ms
110,640 KB
testcase_22 AC 1,272 ms
145,228 KB
testcase_23 AC 75 ms
74,820 KB
testcase_24 AC 88 ms
77,916 KB
testcase_25 AC 181 ms
91,636 KB
testcase_26 AC 682 ms
117,864 KB
testcase_27 AC 744 ms
119,320 KB
testcase_28 AC 1,293 ms
146,760 KB
testcase_29 AC 225 ms
87,272 KB
testcase_30 AC 1,328 ms
150,396 KB
testcase_31 AC 895 ms
129,420 KB
testcase_32 AC 614 ms
110,604 KB
testcase_33 AC 1,530 ms
150,196 KB
testcase_34 AC 526 ms
104,560 KB
testcase_35 AC 1,312 ms
152,680 KB
testcase_36 AC 91 ms
77,408 KB
testcase_37 AC 139 ms
78,584 KB
testcase_38 AC 103 ms
77,092 KB
testcase_39 AC 145 ms
78,716 KB
testcase_40 AC 64 ms
66,856 KB
testcase_41 AC 1,526 ms
152,276 KB
testcase_42 AC 493 ms
100,708 KB
testcase_43 AC 776 ms
117,232 KB
testcase_44 AC 340 ms
92,088 KB
testcase_45 AC 759 ms
116,216 KB
testcase_46 AC 40 ms
53,072 KB
testcase_47 AC 40 ms
52,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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