結果
| 問題 |
No.3087 University Coloring
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-04 21:31:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 551 bytes |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 79,844 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-04-04 21:33:04 |
| 合計ジャッジ時間 | 4,883 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:17: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
23 | for(auto[w,e]:E)
| ^
main.cpp:25:21: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
25 | auto[u,v]=e;
| ^
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<atcoder/dsu>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<pair<int,pair<int,int> > >E(M);
for(int i=0;i<M;i++)
{
int a,b,c;cin>>a>>b>>c;a--,b--;
E[i]=make_pair(c,make_pair(a,b));
}
sort(E.begin(),E.end());
reverse(E.begin(),E.end());
long long ans=0;
atcoder::dsu uf(N);
for(auto[w,e]:E)
{
auto[u,v]=e;
if(!uf.same(u,v))
{
uf.merge(u,v);
ans+=w+w;
}
}
cout<<ans<<endl;
}