結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ttrttr
提出日時 2020-05-29 21:44:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,175 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 147,264 KB
最終ジャッジ日時 2024-04-23 21:07:15
合計ジャッジ時間 27,492 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,120 KB
testcase_01 AC 38 ms
53,248 KB
testcase_02 AC 599 ms
110,140 KB
testcase_03 AC 918 ms
147,264 KB
testcase_04 AC 849 ms
145,596 KB
testcase_05 AC 604 ms
139,664 KB
testcase_06 AC 603 ms
139,916 KB
testcase_07 AC 185 ms
92,756 KB
testcase_08 AC 449 ms
138,752 KB
testcase_09 AC 121 ms
79,616 KB
testcase_10 AC 254 ms
102,156 KB
testcase_11 AC 200 ms
95,872 KB
testcase_12 AC 319 ms
95,368 KB
testcase_13 AC 865 ms
123,112 KB
testcase_14 AC 912 ms
129,568 KB
testcase_15 AC 1,056 ms
138,096 KB
testcase_16 AC 633 ms
108,648 KB
testcase_17 AC 1,105 ms
141,664 KB
testcase_18 AC 488 ms
100,708 KB
testcase_19 AC 1,021 ms
137,684 KB
testcase_20 AC 358 ms
93,820 KB
testcase_21 AC 586 ms
108,400 KB
testcase_22 AC 1,001 ms
133,000 KB
testcase_23 AC 117 ms
77,588 KB
testcase_24 AC 111 ms
78,336 KB
testcase_25 AC 312 ms
94,124 KB
testcase_26 AC 607 ms
111,436 KB
testcase_27 AC 691 ms
110,656 KB
testcase_28 AC 1,113 ms
136,208 KB
testcase_29 AC 243 ms
86,188 KB
testcase_30 AC 1,016 ms
138,708 KB
testcase_31 AC 803 ms
119,156 KB
testcase_32 AC 558 ms
105,116 KB
testcase_33 AC 1,115 ms
136,244 KB
testcase_34 AC 520 ms
100,652 KB
testcase_35 AC 1,175 ms
141,812 KB
testcase_36 AC 116 ms
77,860 KB
testcase_37 AC 143 ms
78,588 KB
testcase_38 AC 115 ms
77,728 KB
testcase_39 AC 144 ms
78,720 KB
testcase_40 AC 73 ms
69,976 KB
testcase_41 AC 1,098 ms
140,808 KB
testcase_42 AC 407 ms
96,948 KB
testcase_43 AC 641 ms
110,908 KB
testcase_44 AC 290 ms
89,856 KB
testcase_45 AC 580 ms
110,180 KB
testcase_46 AC 38 ms
52,992 KB
testcase_47 AC 38 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**12
    d = [inf]*N
    used[s] = 1
    d[s] = 0
    h = []
    for e in E[s]:
        heapq.heappush(h, (e[1], e[0]))
    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

d = dijkstra(X-1)
print(d[Y-1])
0