結果
問題 |
No.3087 University Coloring
|
ユーザー |
|
提出日時 | 2025-04-04 21:44:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 5,833 ms |
コンパイル使用メモリ | 260,868 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-04 21:44:46 |
合計ジャッジ時間 | 13,133 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; int main(){ int N, M; cin >> N >> M; vector<tuple<int, int, int>> E; for (int i = 0; i < M; i++){ int a, b, c; cin >> a >> b >> c; a--; b--; E.push_back(make_tuple(c, a, b)); } sort(E.rbegin(), E.rend()); atcoder::dsu uf(N); long long sum = 0; for (auto [c, a, b] : E){ if (!uf.same(a, b)){ uf.merge(a, b); sum += c * 2; } } cout << sum << endl; }