結果
問題 |
No.1639 最小通信路
|
ユーザー |
|
提出日時 | 2022-10-08 22:22:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 2,424 ms |
コンパイル使用メモリ | 195,064 KB |
最終ジャッジ日時 | 2025-02-08 00:36:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 43 |
ソースコード
#include<bits/stdc++.h> using namespace std; int rt[200]; int getroot(int n){ if(rt[n]==-1)return n; else return rt[n]=getroot(rt[n]); } bool unite(int a,int b){ a=getroot(a),b=getroot(b); if(a!=b){ rt[a]=b; return true; }else{ return false; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; fill(rt,rt+N,-1); string ans=""; for(int i=0;i<N*(N-1)/2;i++){ int a,b; cin>>a>>b; string C; cin>>C; if(unite(a-1,b-1)){ ans=C; } } cout<<ans<<'\n'; }