結果
| 問題 | No.1639 最小通信路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-25 07:36:51 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 930 bytes |
| 記録 | |
| コンパイル時間 | 5,254 ms |
| コンパイル使用メモリ | 257,196 KB |
| 実行使用メモリ | 8,632 KB |
| 最終ジャッジ日時 | 2026-06-21 05:27:45 |
| 合計ジャッジ時間 | 7,244 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include <atcoder/dsu>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cassert>
#include "testlib.h"
using namespace std;
using namespace atcoder;
int main(int argc, char* argv[]) {
registerValidation(argc, argv);
int n = inf.readInt(2, 100, "n");
inf.readEoln();
int m = n * (n - 1) / 2;
vector<int> a(m);
vector<int> b(m);
vector<string> c(m);
for (int i = 0; i < m; i++)
{
a[i] = inf.readInt(1, n, "a_i") - 1;
inf.readSpace();
b[i] = inf.readInt(1, n, "b_i") - 1;
inf.readSpace();
c[i] = inf.readToken("[0-9]{1,101}", "c_i");
inf.readEoln();
}
inf.readEof();
dsu uf(n);
for(int i=0;i<m;i++){
if(uf.same(a[i],b[i]))continue;
uf.merge(a[i],b[i]);
if(uf.size(0)==n){
cout<<c[i]<<endl;
return 0;
}
}
return 0;
}