結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pluto77pluto77
提出日時 2020-06-19 14:30:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,317 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 144,076 KB
最終ジャッジ日時 2023-09-16 12:54:04
合計ジャッジ時間 25,428 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,704 KB
testcase_01 AC 94 ms
71,512 KB
testcase_02 AC 477 ms
110,672 KB
testcase_03 AC 607 ms
142,320 KB
testcase_04 AC 710 ms
142,132 KB
testcase_05 AC 511 ms
137,700 KB
testcase_06 AC 502 ms
137,544 KB
testcase_07 AC 245 ms
95,304 KB
testcase_08 AC 542 ms
143,364 KB
testcase_09 AC 182 ms
84,036 KB
testcase_10 AC 332 ms
107,108 KB
testcase_11 AC 279 ms
98,676 KB
testcase_12 AC 239 ms
90,836 KB
testcase_13 AC 945 ms
114,096 KB
testcase_14 AC 719 ms
122,120 KB
testcase_15 AC 1,041 ms
131,556 KB
testcase_16 AC 614 ms
101,216 KB
testcase_17 AC 1,317 ms
133,040 KB
testcase_18 AC 451 ms
95,148 KB
testcase_19 AC 1,120 ms
131,940 KB
testcase_20 AC 351 ms
92,836 KB
testcase_21 AC 555 ms
99,436 KB
testcase_22 AC 799 ms
124,692 KB
testcase_23 AC 126 ms
78,200 KB
testcase_24 AC 128 ms
78,100 KB
testcase_25 AC 225 ms
88,964 KB
testcase_26 AC 640 ms
109,908 KB
testcase_27 AC 558 ms
107,524 KB
testcase_28 AC 794 ms
128,120 KB
testcase_29 AC 240 ms
85,256 KB
testcase_30 AC 828 ms
135,764 KB
testcase_31 AC 495 ms
118,844 KB
testcase_32 AC 376 ms
103,880 KB
testcase_33 AC 628 ms
132,664 KB
testcase_34 AC 404 ms
96,428 KB
testcase_35 AC 790 ms
136,336 KB
testcase_36 AC 136 ms
78,636 KB
testcase_37 AC 153 ms
78,628 KB
testcase_38 AC 137 ms
78,932 KB
testcase_39 AC 155 ms
78,780 KB
testcase_40 AC 117 ms
77,844 KB
testcase_41 AC 821 ms
144,076 KB
testcase_42 AC 348 ms
99,144 KB
testcase_43 AC 482 ms
112,740 KB
testcase_44 AC 271 ms
91,384 KB
testcase_45 AC 468 ms
112,576 KB
testcase_46 AC 88 ms
71,612 KB
testcase_47 AC 88 ms
71,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1065
from collections import deque
from math import *

N,M=map(int,input().split())
X,Y=map(int,input().split())
X-=1
Y-=1
pq=[list(map(int,input().split())) for i in range(N)]
PQ=[list(map(int,input().split())) for i in range(M)]
edge=[[] for i in range(N)]
for P,Q in PQ:
 edge[P-1].append(Q-1)
 edge[Q-1].append(P-1)

q=deque([X])
res=[float('inf')]*N
res[X]=0
while q:
 i=q.popleft()
 for j in edge[i]:
  a,b=pq[i]
  c,d=pq[j]
  k=res[i]+hypot(a-c,b-d)
  if k<res[j]:
   res[j]=k
   q.append(j)
print(res[Y])
0