結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ttrttr
提出日時 2020-05-29 21:51:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,029 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 146,496 KB
最終ジャッジ日時 2024-04-23 21:43:37
合計ジャッジ時間 26,650 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,120 KB
testcase_01 AC 37 ms
52,864 KB
testcase_02 AC 513 ms
109,888 KB
testcase_03 AC 797 ms
146,384 KB
testcase_04 AC 784 ms
146,496 KB
testcase_05 AC 583 ms
138,620 KB
testcase_06 AC 566 ms
138,636 KB
testcase_07 AC 181 ms
92,928 KB
testcase_08 AC 422 ms
139,264 KB
testcase_09 AC 124 ms
79,244 KB
testcase_10 AC 236 ms
102,216 KB
testcase_11 AC 197 ms
95,852 KB
testcase_12 AC 310 ms
95,172 KB
testcase_13 AC 784 ms
123,324 KB
testcase_14 AC 866 ms
129,772 KB
testcase_15 AC 942 ms
137,140 KB
testcase_16 AC 553 ms
108,428 KB
testcase_17 AC 993 ms
141,328 KB
testcase_18 AC 439 ms
100,480 KB
testcase_19 AC 898 ms
137,924 KB
testcase_20 AC 328 ms
93,696 KB
testcase_21 AC 530 ms
107,208 KB
testcase_22 AC 916 ms
133,528 KB
testcase_23 AC 108 ms
77,416 KB
testcase_24 AC 116 ms
78,464 KB
testcase_25 AC 283 ms
93,056 KB
testcase_26 AC 554 ms
111,684 KB
testcase_27 AC 646 ms
111,568 KB
testcase_28 AC 973 ms
137,220 KB
testcase_29 AC 230 ms
86,468 KB
testcase_30 AC 1,012 ms
138,540 KB
testcase_31 AC 673 ms
118,904 KB
testcase_32 AC 483 ms
104,356 KB
testcase_33 AC 928 ms
136,044 KB
testcase_34 AC 444 ms
100,748 KB
testcase_35 AC 1,029 ms
141,028 KB
testcase_36 AC 107 ms
77,252 KB
testcase_37 AC 136 ms
78,528 KB
testcase_38 AC 111 ms
77,736 KB
testcase_39 AC 139 ms
78,464 KB
testcase_40 AC 77 ms
70,016 KB
testcase_41 AC 982 ms
140,692 KB
testcase_42 AC 344 ms
96,788 KB
testcase_43 AC 559 ms
110,724 KB
testcase_44 AC 260 ms
89,600 KB
testcase_45 AC 513 ms
109,872 KB
testcase_46 AC 39 ms
52,736 KB
testcase_47 AC 36 ms
52,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,M = map(int, input().split())
X,Y = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]
E = [[] for _ in range(N)]
for _ in range(M):
    p,q = map(int, input().split())
    p -= 1
    q -= 1
    d = ((L[p][0]-L[q][0])**2 + (L[p][1]-L[q][1])**2)**0.5
    E[p].append((q, d))
    E[q].append((p, d))

def dijkstra(s):
    used = [0]*N
    inf = 10**10
    d = [inf]*N
    h = [(0, s)]
    while h:
        temp = heapq.heappop(h)
        u = temp[1]
        r = temp[0]
        if used[u] == 1:
            continue
        d[u] = r
        used[u] = 1
        for e in E[u]:
            if used[e[0]] == 1:
                continue
            heapq.heappush(h, (r+e[1], e[0]))
    return d[Y-1]

ans = dijkstra(X-1)
print(ans)
0