//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
llo n,m;
llo par[201];
llo find(llo no){
if(par[no]==no){
return no;
}
par[no]=find(par[no]);
return par[no];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<n;i++){
par[i]=i;
}
vector<pair<pair<llo,llo>,pair<llo,llo>>> ed;
for(llo i=0;i<m;i++){
llo aa,bb,cc,dd;
cin>>aa>>bb>>cc>>dd;
ed.pb({{aa,bb},{cc,dd}});
}
sort(ed.begin(),ed.end());
vector<pair<llo,llo>> ans;
llo su=0;
llo su2=0;
for(auto j:ed){
llo x=find(j.a.a);
llo y=find(j.a.b);
if(x!=y){
par[x]=y;
su+=j.b.a;
su2+=j.b.b;
ans.pb(j.a);
}
}
cout<<su<<" "<<su2<<endl;
for(auto j:ans){
cout<<j.a<<" "<<j.b<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
8 |
Incorrect |
5 ms |
1136 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
19 |
Incorrect |
5 ms |
1136 KB |
Output isn't correct |
20 |
Incorrect |
5 ms |
1136 KB |
Output isn't correct |