結果
問題 | No.1639 最小通信路 |
ユーザー | tcltk |
提出日時 | 2021-10-18 03:25:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 1,767 bytes |
コンパイル時間 | 413 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 90,880 KB |
最終ジャッジ日時 | 2024-09-18 19:14:26 |
合計ジャッジ時間 | 12,364 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
88,152 KB |
testcase_01 | AC | 163 ms
88,804 KB |
testcase_02 | AC | 306 ms
90,796 KB |
testcase_03 | AC | 290 ms
90,744 KB |
testcase_04 | AC | 303 ms
90,816 KB |
testcase_05 | AC | 241 ms
89,812 KB |
testcase_06 | AC | 277 ms
90,212 KB |
testcase_07 | AC | 163 ms
89,088 KB |
testcase_08 | AC | 309 ms
90,848 KB |
testcase_09 | AC | 208 ms
89,120 KB |
testcase_10 | AC | 249 ms
89,548 KB |
testcase_11 | AC | 260 ms
90,472 KB |
testcase_12 | AC | 242 ms
89,700 KB |
testcase_13 | AC | 294 ms
90,752 KB |
testcase_14 | AC | 159 ms
88,600 KB |
testcase_15 | AC | 224 ms
89,416 KB |
testcase_16 | AC | 252 ms
90,240 KB |
testcase_17 | AC | 271 ms
90,556 KB |
testcase_18 | AC | 209 ms
89,468 KB |
testcase_19 | AC | 241 ms
90,112 KB |
testcase_20 | AC | 298 ms
90,880 KB |
testcase_21 | AC | 141 ms
88,412 KB |
testcase_22 | AC | 235 ms
89,828 KB |
testcase_23 | AC | 274 ms
90,084 KB |
testcase_24 | AC | 232 ms
89,272 KB |
testcase_25 | AC | 222 ms
89,252 KB |
testcase_26 | AC | 182 ms
89,088 KB |
testcase_27 | AC | 173 ms
89,164 KB |
testcase_28 | AC | 167 ms
88,912 KB |
testcase_29 | AC | 252 ms
90,240 KB |
testcase_30 | AC | 269 ms
90,580 KB |
testcase_31 | AC | 214 ms
89,740 KB |
testcase_32 | AC | 251 ms
89,964 KB |
testcase_33 | AC | 204 ms
89,240 KB |
testcase_34 | AC | 254 ms
89,984 KB |
testcase_35 | AC | 278 ms
90,752 KB |
testcase_36 | AC | 247 ms
89,908 KB |
testcase_37 | AC | 259 ms
90,204 KB |
testcase_38 | AC | 176 ms
89,020 KB |
testcase_39 | AC | 211 ms
89,600 KB |
testcase_40 | AC | 185 ms
89,112 KB |
testcase_41 | AC | 202 ms
89,416 KB |
testcase_42 | AC | 267 ms
90,476 KB |
testcase_43 | AC | 223 ms
89,216 KB |
testcase_44 | AC | 174 ms
88,908 KB |
ソースコード
#!/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**101 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)