結果
問題 |
No.3087 University Coloring
|
ユーザー |
![]() |
提出日時 | 2025-04-04 21:52:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 7,658 ms |
コンパイル使用メモリ | 332,284 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-04-04 21:52:19 |
合計ジャッジ時間 | 10,418 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<tuple<int, int, int>> edges; rep(i, 0, m) { int a, b, c; cin >> a >> b >> c; edges.emplace_back(c, a - 1, b - 1); } sort(edges.rbegin(), edges.rend()); ll ans = 0; dsu uf(n); for (auto [c, a, b] : edges) { if (uf.same(a, b)) continue; uf.merge(a, b); ans += c; } cout << ans * 2 << '\n'; }