結果

問題 No.1639 最小通信路
ユーザー raven7959raven7959
提出日時 2021-08-17 16:29:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,168 KB
最終ジャッジ日時 2024-04-18 21:29:18
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 34 ms
52,736 KB
testcase_02 AC 68 ms
74,240 KB
testcase_03 AC 80 ms
77,168 KB
testcase_04 AC 80 ms
76,928 KB
testcase_05 AC 71 ms
71,040 KB
testcase_06 AC 66 ms
71,936 KB
testcase_07 AC 37 ms
52,608 KB
testcase_08 AC 66 ms
72,832 KB
testcase_09 AC 39 ms
53,632 KB
testcase_10 AC 47 ms
61,056 KB
testcase_11 AC 66 ms
72,320 KB
testcase_12 AC 51 ms
63,232 KB
testcase_13 AC 69 ms
73,984 KB
testcase_14 AC 37 ms
52,352 KB
testcase_15 AC 48 ms
61,312 KB
testcase_16 AC 70 ms
72,576 KB
testcase_17 AC 66 ms
72,960 KB
testcase_18 AC 39 ms
53,376 KB
testcase_19 AC 64 ms
71,168 KB
testcase_20 AC 69 ms
73,812 KB
testcase_21 AC 38 ms
52,352 KB
testcase_22 AC 54 ms
63,488 KB
testcase_23 AC 66 ms
71,424 KB
testcase_24 AC 50 ms
63,360 KB
testcase_25 AC 47 ms
60,288 KB
testcase_26 AC 38 ms
53,120 KB
testcase_27 AC 35 ms
52,736 KB
testcase_28 AC 34 ms
52,224 KB
testcase_29 AC 69 ms
72,576 KB
testcase_30 AC 69 ms
74,880 KB
testcase_31 AC 43 ms
54,912 KB
testcase_32 AC 70 ms
73,104 KB
testcase_33 AC 40 ms
53,760 KB
testcase_34 AC 71 ms
72,576 KB
testcase_35 AC 79 ms
76,800 KB
testcase_36 AC 70 ms
72,704 KB
testcase_37 AC 68 ms
73,216 KB
testcase_38 AC 37 ms
52,608 KB
testcase_39 AC 47 ms
60,416 KB
testcase_40 AC 40 ms
52,992 KB
testcase_41 AC 41 ms
53,504 KB
testcase_42 AC 71 ms
74,296 KB
testcase_43 AC 40 ms
54,400 KB
testcase_44 AC 41 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
E=[]
for i in range(N*(N-1)//2):
  a,b,c=map(int,input().split())
  E.append((c,a-1,b-1))
par=[i for i in range(N)]
rank=[0]*(N+1)
def root(x):
  if par[x]==x:
    return x
  else:
    par[x]=root(par[x])
    return par[x]
def unite(x,y):
  rx,ry=root(x),root(y)
  if rx==ry:
    return
  else:
    if rank[x]<rank[y]:
      par[rx]=ry
    else:
      par[ry]=rx
      if rank[x]==rank[y]:
        rank[x]+=1
def same(x,y):
  rx,ry=root(x),root(y)
  return rx==ry
max_cost=0
for cost,s,g in E:
  if not same(s,g):
    max_cost=cost
    unite(s,g)
print(max_cost)
0