結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー tobusakanatobusakana
提出日時 2022-12-10 20:11:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,192 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 162,692 KB
最終ジャッジ日時 2024-04-23 00:45:00
合計ジャッジ時間 28,231 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,120 KB
testcase_01 AC 43 ms
53,120 KB
testcase_02 AC 550 ms
114,828 KB
testcase_03 AC 913 ms
161,620 KB
testcase_04 AC 1,073 ms
162,692 KB
testcase_05 AC 707 ms
161,960 KB
testcase_06 AC 725 ms
161,712 KB
testcase_07 AC 216 ms
96,172 KB
testcase_08 AC 541 ms
152,448 KB
testcase_09 AC 154 ms
83,712 KB
testcase_10 AC 300 ms
111,232 KB
testcase_11 AC 240 ms
99,712 KB
testcase_12 AC 222 ms
96,128 KB
testcase_13 AC 872 ms
135,372 KB
testcase_14 AC 837 ms
139,488 KB
testcase_15 AC 1,043 ms
150,868 KB
testcase_16 AC 570 ms
117,288 KB
testcase_17 AC 1,192 ms
156,896 KB
testcase_18 AC 520 ms
108,188 KB
testcase_19 AC 914 ms
152,772 KB
testcase_20 AC 402 ms
98,440 KB
testcase_21 AC 620 ms
118,400 KB
testcase_22 AC 1,016 ms
147,848 KB
testcase_23 AC 111 ms
77,952 KB
testcase_24 AC 88 ms
77,288 KB
testcase_25 AC 207 ms
95,120 KB
testcase_26 AC 494 ms
115,072 KB
testcase_27 AC 553 ms
119,808 KB
testcase_28 AC 815 ms
148,220 KB
testcase_29 AC 247 ms
89,384 KB
testcase_30 AC 829 ms
148,612 KB
testcase_31 AC 767 ms
130,476 KB
testcase_32 AC 395 ms
108,160 KB
testcase_33 AC 1,031 ms
150,024 KB
testcase_34 AC 493 ms
108,340 KB
testcase_35 AC 757 ms
146,816 KB
testcase_36 AC 89 ms
74,496 KB
testcase_37 AC 122 ms
78,080 KB
testcase_38 AC 99 ms
77,312 KB
testcase_39 AC 108 ms
77,312 KB
testcase_40 AC 60 ms
65,280 KB
testcase_41 AC 1,140 ms
152,860 KB
testcase_42 AC 405 ms
100,864 KB
testcase_43 AC 571 ms
116,992 KB
testcase_44 AC 282 ms
92,852 KB
testcase_45 AC 650 ms
116,480 KB
testcase_46 AC 40 ms
52,608 KB
testcase_47 AC 41 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
X,Y = map(int,input().split())
PQ = [list(map(int,input().split())) for i in range(N)]

import heapq as hq
q = []
hq.heappush(q, (0, X - 1))
G = [[] for i in range(N)]
for _ in range(M):
    i,j = map(lambda x:int(x) - 1,input().split())
    d = ((PQ[i][0] - PQ[j][0]) ** 2 + (PQ[i][1] - PQ[j][1]) ** 2) ** 0.5
    G[i].append([j, d])
    G[j].append([i, d])
    
visited = [False] * N
while q:
    dist, v = hq.heappop(q)
    if visited[v]:
        continue
    visited[v] = True
    if v == Y - 1:
        print(dist)
        break
    for child, d in G[v]:
        if visited[child]:
            continue
        hq.heappush(q, (dist + d, child))
0