結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー paruf4paruf4
提出日時 2020-05-29 22:37:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,243 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 159,220 KB
最終ジャッジ日時 2024-04-23 23:56:07
合計ジャッジ時間 28,018 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,376 KB
testcase_01 AC 40 ms
53,120 KB
testcase_02 AC 722 ms
117,816 KB
testcase_03 AC 962 ms
159,220 KB
testcase_04 AC 950 ms
158,116 KB
testcase_05 AC 747 ms
158,444 KB
testcase_06 AC 754 ms
158,304 KB
testcase_07 AC 207 ms
97,192 KB
testcase_08 AC 486 ms
151,680 KB
testcase_09 AC 138 ms
83,968 KB
testcase_10 AC 262 ms
110,208 KB
testcase_11 AC 218 ms
99,784 KB
testcase_12 AC 186 ms
95,616 KB
testcase_13 AC 871 ms
133,152 KB
testcase_14 AC 926 ms
139,144 KB
testcase_15 AC 1,165 ms
150,248 KB
testcase_16 AC 600 ms
114,344 KB
testcase_17 AC 1,228 ms
156,656 KB
testcase_18 AC 405 ms
104,320 KB
testcase_19 AC 1,112 ms
152,920 KB
testcase_20 AC 370 ms
97,408 KB
testcase_21 AC 470 ms
110,636 KB
testcase_22 AC 1,083 ms
145,816 KB
testcase_23 AC 76 ms
74,276 KB
testcase_24 AC 89 ms
77,848 KB
testcase_25 AC 176 ms
91,392 KB
testcase_26 AC 620 ms
117,344 KB
testcase_27 AC 656 ms
119,192 KB
testcase_28 AC 1,105 ms
146,560 KB
testcase_29 AC 217 ms
87,000 KB
testcase_30 AC 1,127 ms
150,288 KB
testcase_31 AC 767 ms
129,552 KB
testcase_32 AC 546 ms
110,612 KB
testcase_33 AC 1,243 ms
150,204 KB
testcase_34 AC 446 ms
104,704 KB
testcase_35 AC 1,124 ms
152,688 KB
testcase_36 AC 92 ms
77,184 KB
testcase_37 AC 135 ms
78,720 KB
testcase_38 AC 102 ms
77,312 KB
testcase_39 AC 134 ms
78,720 KB
testcase_40 AC 62 ms
66,304 KB
testcase_41 AC 1,210 ms
152,320 KB
testcase_42 AC 434 ms
100,656 KB
testcase_43 AC 669 ms
117,376 KB
testcase_44 AC 312 ms
91,904 KB
testcase_45 AC 649 ms
116,224 KB
testcase_46 AC 38 ms
52,992 KB
testcase_47 AC 39 ms
52,864 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