結果

問題 No.1639 最小通信路
ユーザー tonyu0tonyu0
提出日時 2022-09-21 18:51:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 9,124 KB
最終ジャッジ日時 2023-08-23 20:07:44
合計ジャッジ時間 2,642 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,888 KB
testcase_01 AC 16 ms
7,768 KB
testcase_02 AC 36 ms
8,824 KB
testcase_03 AC 36 ms
9,124 KB
testcase_04 AC 40 ms
9,020 KB
testcase_05 AC 20 ms
8,252 KB
testcase_06 AC 23 ms
8,396 KB
testcase_07 AC 16 ms
7,764 KB
testcase_08 AC 28 ms
8,788 KB
testcase_09 AC 17 ms
7,748 KB
testcase_10 AC 18 ms
8,176 KB
testcase_11 AC 25 ms
8,536 KB
testcase_12 AC 19 ms
8,240 KB
testcase_13 AC 32 ms
8,924 KB
testcase_14 AC 16 ms
7,760 KB
testcase_15 AC 18 ms
8,372 KB
testcase_16 AC 25 ms
8,556 KB
testcase_17 AC 29 ms
8,632 KB
testcase_18 AC 16 ms
7,828 KB
testcase_19 AC 20 ms
8,280 KB
testcase_20 AC 29 ms
8,800 KB
testcase_21 AC 15 ms
7,748 KB
testcase_22 AC 19 ms
8,188 KB
testcase_23 AC 23 ms
8,464 KB
testcase_24 AC 19 ms
8,332 KB
testcase_25 AC 17 ms
8,188 KB
testcase_26 AC 16 ms
7,780 KB
testcase_27 AC 16 ms
7,764 KB
testcase_28 AC 16 ms
7,792 KB
testcase_29 AC 21 ms
8,448 KB
testcase_30 AC 25 ms
8,620 KB
testcase_31 AC 17 ms
8,296 KB
testcase_32 AC 22 ms
8,444 KB
testcase_33 AC 17 ms
7,892 KB
testcase_34 AC 21 ms
8,600 KB
testcase_35 AC 30 ms
8,844 KB
testcase_36 AC 21 ms
8,348 KB
testcase_37 AC 22 ms
8,524 KB
testcase_38 AC 16 ms
7,748 KB
testcase_39 AC 18 ms
8,232 KB
testcase_40 AC 16 ms
7,768 KB
testcase_41 AC 16 ms
7,680 KB
testcase_42 AC 24 ms
8,632 KB
testcase_43 AC 17 ms
7,888 KB
testcase_44 AC 16 ms
7,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a = []
par=[-1]*n

def root(x):
    if par[x] < 0:return x
    return root(par[x])
def same(x,y):
    return root(x)==root(y)
def merge(x, y):
    if same(x,y):return
    x=root(x)
    y=root(y)
    if par[x]>par[y]:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x
def sz(x):
    return -par[root(x)]

for _ in range(n*(n-1)//2):
    x,y,z=map(int,input().split())
    x-=1
    y-=1
    a.append([z, x, y])

for z,x,y in a:
    merge(x, y)
    if sz(0)==n:
        print(z)
        break
0