結果

問題 No.1639 最小通信路
ユーザー momoyuumomoyuu
提出日時 2022-08-03 01:19:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 78,512 KB
最終ジャッジ日時 2023-10-01 02:02:18
合計ジャッジ時間 7,126 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,432 KB
testcase_01 AC 70 ms
71,236 KB
testcase_02 AC 111 ms
78,268 KB
testcase_03 AC 122 ms
78,320 KB
testcase_04 AC 123 ms
78,332 KB
testcase_05 AC 98 ms
77,096 KB
testcase_06 AC 109 ms
78,352 KB
testcase_07 AC 73 ms
71,492 KB
testcase_08 AC 108 ms
78,328 KB
testcase_09 AC 77 ms
71,376 KB
testcase_10 AC 86 ms
76,144 KB
testcase_11 AC 101 ms
77,900 KB
testcase_12 AC 90 ms
76,868 KB
testcase_13 AC 101 ms
78,144 KB
testcase_14 AC 70 ms
71,348 KB
testcase_15 AC 87 ms
76,368 KB
testcase_16 AC 110 ms
77,844 KB
testcase_17 AC 111 ms
78,200 KB
testcase_18 AC 74 ms
71,436 KB
testcase_19 AC 105 ms
77,816 KB
testcase_20 AC 108 ms
78,232 KB
testcase_21 AC 67 ms
71,296 KB
testcase_22 AC 87 ms
76,656 KB
testcase_23 AC 100 ms
77,800 KB
testcase_24 AC 87 ms
76,364 KB
testcase_25 AC 81 ms
75,340 KB
testcase_26 AC 71 ms
71,492 KB
testcase_27 AC 73 ms
71,188 KB
testcase_28 AC 72 ms
71,656 KB
testcase_29 AC 107 ms
78,336 KB
testcase_30 AC 114 ms
78,380 KB
testcase_31 AC 78 ms
75,428 KB
testcase_32 AC 108 ms
78,512 KB
testcase_33 AC 77 ms
75,352 KB
testcase_34 AC 107 ms
78,320 KB
testcase_35 AC 120 ms
78,512 KB
testcase_36 AC 107 ms
77,836 KB
testcase_37 AC 106 ms
78,260 KB
testcase_38 AC 71 ms
71,300 KB
testcase_39 AC 80 ms
75,684 KB
testcase_40 AC 74 ms
71,616 KB
testcase_41 AC 76 ms
71,652 KB
testcase_42 AC 109 ms
78,048 KB
testcase_43 AC 78 ms
71,624 KB
testcase_44 AC 72 ms
71,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
abc = [list(map(int,input().split( ))) for _ in range(N*(N-1)//2)]
class unionfind:
    """
    0-index
    数字でやるときはこっちがいいっぽい。
    """
    def __init__(self,n):
        self.n = n
        self.parents = [i for i in range(n)]
    
    def find(self,x):
        if x == self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if y < x:
            x,y = y,x
        self.parents[y] = x

    def same(self,x,y):
        return self.find(x) == self.find(y)
    
u = unionfind(N)

for i in range(N*(N-1)//2):
    a,b,c = abc[i]
    u.union(a-1,b-1)
    p = True
    for j in range(N):
        for k in range(j+1,N):
            if u.same(j,k):
                continue
            p = False
            break
        if not p:
            break
    if p:
        print(c)
        exit()



0