結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー 👑 KazunKazun
提出日時 2021-02-10 18:17:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 809 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 150,496 KB
最終ジャッジ日時 2023-09-22 13:16:02
合計ジャッジ時間 20,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,296 KB
testcase_01 AC 76 ms
71,060 KB
testcase_02 AC 475 ms
113,364 KB
testcase_03 AC 590 ms
150,496 KB
testcase_04 AC 614 ms
149,932 KB
testcase_05 AC 362 ms
146,900 KB
testcase_06 AC 366 ms
147,140 KB
testcase_07 AC 161 ms
95,100 KB
testcase_08 AC 323 ms
145,124 KB
testcase_09 AC 126 ms
83,496 KB
testcase_10 AC 203 ms
106,580 KB
testcase_11 AC 173 ms
97,708 KB
testcase_12 AC 137 ms
82,440 KB
testcase_13 AC 537 ms
120,416 KB
testcase_14 AC 586 ms
130,944 KB
testcase_15 AC 693 ms
140,756 KB
testcase_16 AC 387 ms
100,344 KB
testcase_17 AC 698 ms
146,492 KB
testcase_18 AC 309 ms
93,308 KB
testcase_19 AC 678 ms
145,236 KB
testcase_20 AC 281 ms
95,648 KB
testcase_21 AC 334 ms
96,288 KB
testcase_22 AC 642 ms
136,720 KB
testcase_23 AC 88 ms
76,880 KB
testcase_24 AC 96 ms
77,104 KB
testcase_25 AC 135 ms
82,464 KB
testcase_26 AC 393 ms
110,460 KB
testcase_27 AC 398 ms
107,224 KB
testcase_28 AC 658 ms
132,528 KB
testcase_29 AC 199 ms
82,456 KB
testcase_30 AC 675 ms
141,464 KB
testcase_31 AC 485 ms
126,348 KB
testcase_32 AC 363 ms
107,500 KB
testcase_33 AC 809 ms
146,880 KB
testcase_34 AC 340 ms
96,652 KB
testcase_35 AC 665 ms
142,568 KB
testcase_36 AC 109 ms
77,724 KB
testcase_37 AC 143 ms
79,276 KB
testcase_38 AC 116 ms
78,484 KB
testcase_39 AC 143 ms
79,176 KB
testcase_40 AC 88 ms
76,388 KB
testcase_41 AC 721 ms
145,292 KB
testcase_42 AC 312 ms
98,312 KB
testcase_43 AC 457 ms
114,120 KB
testcase_44 AC 246 ms
91,628 KB
testcase_45 AC 426 ms
111,896 KB
testcase_46 AC 73 ms
71,384 KB
testcase_47 AC 77 ms
71,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
def dist(p,q):
    return sqrt((p[0]-q[0])**2+(p[1]-q[1])**2)

class A:
    def __init__(self,d,x):
        self.d=d
        self.x=x

    def __le__(self,other):
        return self.d<=other.d

    def __lt__(self,other):
        return self.d<other.d

    def __iter__(self):
        yield from (self.d,self.x)
#================================================
import sys
from heapq import heappop,heappush
input=sys.stdin.readline

N,M=map(int,input().split())
X,Y=map(int,input().split())
Pos=[("*","*")]
for _ in range(N):
    x,y=map(int,input().split())
    Pos.append((x,y))

E=[set() for _ in range(N+1)]
for _ in range(M):
    p,q=map(int,input().split())
    E[p].add(q)
    E[q].add(p)

inf=float("inf")
T=[inf]*(N+1)
T[X]=0
Q=[A(0,X)]
while Q:
    c,p=heappop(Q)
    if T[p]<c:
        continue

    for q in E[p]:
        if T[q]>c+dist(Pos[p],Pos[q]):
            T[q]=c+dist(Pos[p],Pos[q])
            heappush(Q,A(c+dist(Pos[p],Pos[q]),q))

print(T[Y])
0