結果

問題 No.1639 最小通信路
ユーザー tcltktcltk
提出日時 2021-10-18 03:22:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,765 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 89,444 KB
最終ジャッジ日時 2023-10-18 23:10:42
合計ジャッジ時間 9,917 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
85,716 KB
testcase_01 AC 139 ms
85,720 KB
testcase_02 AC 206 ms
89,420 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 179 ms
88,784 KB
testcase_06 AC 193 ms
88,828 KB
testcase_07 AC 137 ms
85,720 KB
testcase_08 AC 205 ms
89,276 KB
testcase_09 AC 156 ms
88,060 KB
testcase_10 AC 169 ms
88,296 KB
testcase_11 AC 193 ms
88,808 KB
testcase_12 AC 182 ms
88,324 KB
testcase_13 AC 206 ms
89,444 KB
testcase_14 AC 138 ms
85,720 KB
testcase_15 AC 172 ms
88,276 KB
testcase_16 AC 198 ms
88,844 KB
testcase_17 AC 199 ms
89,240 KB
testcase_18 AC 162 ms
88,108 KB
testcase_19 AC 185 ms
88,784 KB
testcase_20 AC 204 ms
89,356 KB
testcase_21 AC 134 ms
85,720 KB
testcase_22 AC 174 ms
88,272 KB
testcase_23 AC 193 ms
88,824 KB
testcase_24 AC 170 ms
88,252 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10
class UnionFind():
    parents = []
    sizes = []
    count = 0
    def __init__(self, n):
        self.count = n
        self.parents = [i for i in range(n)]
        self.sizes = [1 for i in range(n)]
    def find(self, i):
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i])
            return self.parents[i]
    def unite(self, i, j):
        root_i = self.find(i)
        root_j = self.find(j)
        if root_i == root_j:
            return
        elif root_i < root_j:
            self.parents[root_j] = root_i
            self.sizes[root_i] += self.sizes[root_j]
        else:
            self.parents[root_i] = root_j
            self.sizes[root_j] += self.sizes[root_i]
    def same(self, i, j):
        return self.find(i) == self.find(j)
    def size(self, i):
        return self.sizes[self.find(i)]
    def group_count(self):
        return len(set(self.find(i) for i in range(self.count)))

def check(r):
    uf = UnionFind(N)
    for a, b, c in L:
        if c <= r:
            uf.unite(a, b)
    for i in range(N):
        if not uf.same(i, 0):
            return False
    return True

N = int(input())
L = []
for _ in range(N*(N-1)//2):
    a, b, c = map(int, input().split())
    L.append((a-1, b-1, c))

ok = INF
ng = 0
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0