結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-29 23:58:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 896 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 159,660 KB
最終ジャッジ日時 2024-04-24 02:34:31
合計ジャッジ時間 6,900 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,512 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
N, M = map(int, input().split())
X, Y = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(N)]
D = {}
DD = {}
for i in range(M):
    P, Q = map(int, input().split())
    if P-1 in D:
        D[P-1].append(Q-1)
    else:
        D[P-1] = [Q-1]
    if Q-1 in D:
        D[Q-1].append(P-1)
    else:
        D[Q-1] = [P-1]
    DD[(P-1)*N+(Q-1)] = ((p[P-1][0]-p[Q-1][0])**2+(p[P-1][1]-p[Q-1][1])**2) ** 0.5
    DD[(Q-1)*N+(P-1)] = ((p[P-1][0]-p[Q-1][0])**2+(p[P-1][1]-p[Q-1][1])**2) ** 0.5
dist = [int(1e18) for _ in range(N)]
dist[X-1] = 0
pq = []
for i in range(N):
    heappush(pq, [dist[i], i])
while pq != []:
    b = heappop(pq)
    r = b[1]
    if r in D:
        for i in D[r]:
            if dist[i] > dist[r] + DD[r*N+i]:
                dist[i] = dist[r] + DD[r*N+i]
                heappush(pq, [dist[i], i])
print(dist[Y-1])
0