結果
| 問題 |
No.1639 最小通信路
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-08-06 22:02:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 924 bytes |
| コンパイル時間 | 1,282 ms |
| コンパイル使用メモリ | 92,588 KB |
| 最終ジャッジ日時 | 2025-01-23 15:24:46 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/dsu>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
vector<pair<string,pair<int,int>>> E;
int main(){
cin >> N;
rep(i,N*(N-1)/2){
int a,b; cin >> a >> b; a--; b--;
string C; cin >> C;
reverse(C.begin(),C.end());
C.resize(100,'0');
reverse(C.begin(),C.end());
E.push_back({C,{a,b}});
}
sort(E.begin(),E.end());
atcoder::dsu G(N);
for(auto& e : E){
G.merge(e.second.first,e.second.second);
if(G.size(0) < N) continue;
auto c = e.first;
reverse(c.begin(),c.end());
while(c.back() == '0') c.pop_back();
reverse(c.begin(),c.end());
cout << c << endl;
break;
}
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia