結果
問題 | No.1639 最小通信路 |
ユーザー |
![]() |
提出日時 | 2022-08-03 01:19:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 82,032 KB |
実行使用メモリ | 77,720 KB |
最終ジャッジ日時 | 2024-07-23 19:32:54 |
合計ジャッジ時間 | 4,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 43 |
ソースコード
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()