結果

問題 No.1639 最小通信路
ユーザー eve__fuyuki
提出日時 2024-05-21 14:36:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 200,940 KB
最終ジャッジ日時 2025-02-21 16:24:22
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n;
    cin >> n;
    string ans = "";
    dsu uf(n);
    for (int i = 0; i < n * (n - 1) / 2; i++) {
        int a, b;
        string c;
        cin >> a >> b >> c;
        a--, b--;
        if (!uf.same(a, b)) {
            uf.merge(a, b);
            ans = c;
        }
    }
    cout << ans << endl;
}
0