結果

問題 No.1639 最小通信路
ユーザー 330Xs
提出日時 2022-02-06 14:15:23
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 555 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 538,936 KB
最終ジャッジ日時 2024-06-11 13:46:06
合計ジャッジ時間 4,272 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other MLE * 1 -- * 42
権限があれば一括ダウンロードができます

ソースコード

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