結果

問題 No.1639 最小通信路
ユーザー 330Xs330Xs
提出日時 2022-02-06 14:15:23
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 555 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 607,828 KB
最終ジャッジ日時 2023-09-02 06:58:32
合計ジャッジ時間 5,997 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,776 KB
testcase_01 AC 71 ms
71,180 KB
testcase_02 MLE -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n*(n-1)//2):
    a,b,c = map(int,input().split())
    to[a-1].append([c,b-1])
    to[b-1].append([c,a-1])
    
cost = [10 ** 101] * n
cost[0] = 0
visited = [False] * n
visited[0] = 0

lis = []
heapq.heapify(lis)
heapq.heappush(lis,(0,0))
while(lis):
    cc,a = heapq.heappop(lis)
    for c2,v in to[a]:
        if((visited[v]) & (cost[v] < c2)):
            continue
        visited[v] = True
        cost[v] = min(cost[v],c2)
        heapq.heappush(lis,(cost[v],v))
print(cost[-1])
0