結果
| 問題 | 
                            No.1639 最小通信路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-04-12 19:50:16 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 714 bytes | 
| コンパイル時間 | 302 ms | 
| コンパイル使用メモリ | 82,720 KB | 
| 実行使用メモリ | 107,740 KB | 
| 最終ジャッジ日時 | 2024-12-21 05:22:37 | 
| 合計ジャッジ時間 | 138,991 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | TLE * 2 | 
| other | TLE * 43 | 
ソースコード
from collections import deque
n=int(input())
g=[[] for _ in range(n)]
for _ in range(n*(n-1)//2):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    g[a].append((b,c))
    g[b].append((a,c))
def f(d):
    visit=[False]*n
    q=deque()
    q.append(n-1)
    while q:
        now=q.popleft()
        if visit[now]:
            continue
        visit[now]=True
        for to,cost in g[now]:
            if cost>d:
                continue
            if visit[to]:
                continue
            q.append(to)
    for i in visit:
        if i==False:
            return False
    return True
ok=10**100000
ng=0
while ok-ng>1:
    mid=(ok+ng)//2
    if f(mid):
        ok=mid
    else:
        ng=mid
print(ok)