結果

問題 No.1639 最小通信路
ユーザー harurun
提出日時 2021-06-22 01:56:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 80,876 KB
最終ジャッジ日時 2025-01-22 11:03:41
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/dsu>
#include <iostream>
#include <string>
using namespace std;
using namespace atcoder;

int main(){
  int N,M,a,b;
  string s;
  cin>>N;
  M=N*(N-1)/2;
  dsu uf(N);
  for(int i=0;i<M;i++){
    cin>>a>>b>>s;
    a--;b--;
    if(uf.same(a,b))continue;
    uf.merge(a,b);
    if(uf.size(0)==N){
      cout<<s<<endl;
      return 0;
    }
  }
  return 0;
}
0