結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pluto77pluto77
提出日時 2020-06-19 13:12:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,400 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 161,964 KB
最終ジャッジ日時 2023-09-16 12:46:17
合計ジャッジ時間 33,647 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,956 KB
testcase_01 AC 72 ms
71,752 KB
testcase_02 AC 814 ms
120,120 KB
testcase_03 AC 1,134 ms
161,964 KB
testcase_04 AC 1,158 ms
161,612 KB
testcase_05 AC 846 ms
160,692 KB
testcase_06 AC 831 ms
160,632 KB
testcase_07 AC 237 ms
97,336 KB
testcase_08 AC 529 ms
156,804 KB
testcase_09 AC 168 ms
84,836 KB
testcase_10 AC 301 ms
113,576 KB
testcase_11 AC 248 ms
102,064 KB
testcase_12 AC 216 ms
97,624 KB
testcase_13 AC 988 ms
135,424 KB
testcase_14 AC 1,056 ms
142,728 KB
testcase_15 AC 1,259 ms
153,316 KB
testcase_16 AC 677 ms
116,868 KB
testcase_17 AC 1,313 ms
160,192 KB
testcase_18 AC 490 ms
105,604 KB
testcase_19 AC 1,185 ms
155,420 KB
testcase_20 AC 411 ms
100,004 KB
testcase_21 AC 529 ms
113,036 KB
testcase_22 AC 1,167 ms
148,640 KB
testcase_23 AC 108 ms
78,128 KB
testcase_24 AC 113 ms
78,100 KB
testcase_25 AC 207 ms
92,944 KB
testcase_26 AC 661 ms
121,144 KB
testcase_27 AC 702 ms
121,432 KB
testcase_28 AC 1,214 ms
150,324 KB
testcase_29 AC 254 ms
88,328 KB
testcase_30 AC 1,226 ms
153,476 KB
testcase_31 AC 846 ms
131,672 KB
testcase_32 AC 608 ms
112,972 KB
testcase_33 AC 1,400 ms
155,032 KB
testcase_34 AC 506 ms
107,836 KB
testcase_35 AC 1,210 ms
155,124 KB
testcase_36 AC 117 ms
79,296 KB
testcase_37 AC 166 ms
79,324 KB
testcase_38 AC 126 ms
79,248 KB
testcase_39 AC 165 ms
80,028 KB
testcase_40 AC 92 ms
77,012 KB
testcase_41 AC 1,309 ms
157,864 KB
testcase_42 AC 474 ms
103,068 KB
testcase_43 AC 738 ms
121,108 KB
testcase_44 AC 351 ms
94,128 KB
testcase_45 AC 725 ms
119,388 KB
testcase_46 AC 72 ms
71,300 KB
testcase_47 AC 70 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=[list(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