結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー takakintakakin
提出日時 2020-06-03 23:58:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,358 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 161,372 KB
最終ジャッジ日時 2024-05-04 20:09:39
合計ジャッジ時間 30,350 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,992 KB
testcase_01 AC 37 ms
52,992 KB
testcase_02 AC 620 ms
116,900 KB
testcase_03 AC 1,097 ms
159,400 KB
testcase_04 AC 1,061 ms
160,152 KB
testcase_05 AC 768 ms
156,368 KB
testcase_06 AC 762 ms
156,576 KB
testcase_07 AC 153 ms
92,288 KB
testcase_08 AC 371 ms
151,296 KB
testcase_09 AC 103 ms
80,128 KB
testcase_10 AC 224 ms
109,952 KB
testcase_11 AC 174 ms
97,408 KB
testcase_12 AC 457 ms
105,776 KB
testcase_13 AC 997 ms
138,164 KB
testcase_14 AC 1,059 ms
145,628 KB
testcase_15 AC 1,256 ms
154,432 KB
testcase_16 AC 757 ms
121,464 KB
testcase_17 AC 1,358 ms
161,372 KB
testcase_18 AC 588 ms
109,636 KB
testcase_19 AC 1,107 ms
154,096 KB
testcase_20 AC 369 ms
98,304 KB
testcase_21 AC 751 ms
121,924 KB
testcase_22 AC 1,183 ms
149,988 KB
testcase_23 AC 101 ms
77,696 KB
testcase_24 AC 114 ms
77,696 KB
testcase_25 AC 403 ms
101,760 KB
testcase_26 AC 686 ms
121,492 KB
testcase_27 AC 827 ms
124,432 KB
testcase_28 AC 1,339 ms
157,076 KB
testcase_29 AC 259 ms
89,600 KB
testcase_30 AC 1,230 ms
156,580 KB
testcase_31 AC 799 ms
130,512 KB
testcase_32 AC 564 ms
112,128 KB
testcase_33 AC 1,222 ms
152,424 KB
testcase_34 AC 544 ms
109,696 KB
testcase_35 AC 1,247 ms
159,592 KB
testcase_36 AC 100 ms
77,312 KB
testcase_37 AC 110 ms
78,336 KB
testcase_38 AC 106 ms
77,524 KB
testcase_39 AC 113 ms
78,080 KB
testcase_40 AC 65 ms
67,456 KB
testcase_41 AC 1,041 ms
151,040 KB
testcase_42 AC 352 ms
99,768 KB
testcase_43 AC 579 ms
116,380 KB
testcase_44 AC 250 ms
91,904 KB
testcase_45 AC 535 ms
115,712 KB
testcase_46 AC 42 ms
52,608 KB
testcase_47 AC 42 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
x,y=map(int,input().split())
PQ=[tuple(int(i) for i in input().split()) for _ in range(n)]

def f(A,B):
  a1,a2=A
  b1,b2=B
  return ((a1-b1)**2+(a2-b2)**2)**0.5

edge=[[] for i in range(n)]
for _ in range(m):
  p,q=map(int,input().split())
  dis=f(PQ[p-1],PQ[q-1])
  edge[p-1].append([dis,q-1])
  edge[q-1].append([dis,p-1])

import heapq
def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge = heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v = minedge[1]
    d[v] = minedge[0]
    used[v] = False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d
print(dijkstra_heap(x-1)[y-1])
0