結果
問題 |
No.3087 University Coloring
|
ユーザー |
![]() |
提出日時 | 2025-04-04 22:46:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 3,054 ms |
コンパイル使用メモリ | 212,552 KB |
実行使用メモリ | 22,620 KB |
最終ジャッジ日時 | 2025-04-04 22:46:26 |
合計ジャッジ時間 | 6,682 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 32 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/dsu> using namespace std; using namespace atcoder; #define int long long int N,M; int ans = 0; vector<tuple<int,int,int>> G(200001); vector<bool> visited(200001); signed main(){ cin>>N>>M; dsu d(N+1); for(int i = 0; i < M; i++){ int a,b,c; cin>>a>>b>>c; G.push_back(make_tuple(c,a,b)); } for(int i = 1; i <= N; i++) sort(G.rbegin(),G.rend()); for(int i = 0; i < M; i++){ int a = get<1>(G[i]); int b = get<2>(G[i]); int c = get<0>(G[i]); if(!d.same(a,b)){ d.merge(a,b); ans += c; } } cout << ans*2 << endl; }