結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー 👑 KazunKazun
提出日時 2021-02-10 18:14:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 796 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 146,872 KB
最終ジャッジ日時 2023-09-22 13:12:23
合計ジャッジ時間 23,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,380 KB
testcase_01 AC 78 ms
71,392 KB
testcase_02 AC 480 ms
113,400 KB
testcase_03 AC 629 ms
146,872 KB
testcase_04 AC 608 ms
146,240 KB
testcase_05 AC 430 ms
145,880 KB
testcase_06 AC 422 ms
145,928 KB
testcase_07 AC 157 ms
92,576 KB
testcase_08 AC 322 ms
145,060 KB
testcase_09 AC 118 ms
79,452 KB
testcase_10 AC 198 ms
106,648 KB
testcase_11 AC 168 ms
97,888 KB
testcase_12 AC 136 ms
82,556 KB
testcase_13 AC 554 ms
118,364 KB
testcase_14 AC 601 ms
127,556 KB
testcase_15 AC 698 ms
137,864 KB
testcase_16 AC 377 ms
98,472 KB
testcase_17 AC 738 ms
142,948 KB
testcase_18 AC 299 ms
92,172 KB
testcase_19 AC 674 ms
140,792 KB
testcase_20 AC 261 ms
93,936 KB
testcase_21 AC 288 ms
95,348 KB
testcase_22 AC 667 ms
133,128 KB
testcase_23 AC 88 ms
76,748 KB
testcase_24 AC 94 ms
77,120 KB
testcase_25 AC 132 ms
82,656 KB
testcase_26 AC 392 ms
109,220 KB
testcase_27 AC 434 ms
105,384 KB
testcase_28 AC 669 ms
128,688 KB
testcase_29 AC 181 ms
81,816 KB
testcase_30 AC 695 ms
138,208 KB
testcase_31 AC 486 ms
123,288 KB
testcase_32 AC 379 ms
106,340 KB
testcase_33 AC 796 ms
143,132 KB
testcase_34 AC 334 ms
95,772 KB
testcase_35 AC 687 ms
139,208 KB
testcase_36 AC 106 ms
78,248 KB
testcase_37 AC 134 ms
79,336 KB
testcase_38 AC 113 ms
78,476 KB
testcase_39 AC 136 ms
79,720 KB
testcase_40 AC 89 ms
76,716 KB
testcase_41 AC 779 ms
145,372 KB
testcase_42 AC 294 ms
98,716 KB
testcase_43 AC 457 ms
112,708 KB
testcase_44 AC 243 ms
91,448 KB
testcase_45 AC 422 ms
112,304 KB
testcase_46 AC 76 ms
71,260 KB
testcase_47 AC 75 ms
71,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
def dist(p,q):
    return sqrt((p[0]-q[0])**2+(p[1]-q[1])**2)
#================================================
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=[(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,(c+dist(Pos[p],Pos[q]),q))

print(T[Y])
0