#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,p[220],ta,tb,tc,td,h1,h2;
pair<pair<ll,ll>,pair<ll,ll> > E[10101];
vector<pair<ll,ll> > isi;
ll car(ll aa)
{
if(p[aa]==aa)return aa;
else return p[aa]=car(p[aa]);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(i=0;i<n;i++)p[i]=i;
for(i=1;i<=m;i++)
{
cin>>ta>>tb>>tc>>td;
E[i]=mp(mp(tc,td),mp(ta,tb));
h2+=td;
}
sort(E+1,E+1+m);
for(i=1;i<=m;i++)
{
if(car(E[i].se.fi)!=car(E[i].se.se))
{
h1+=E[i].fi.fi;
p[car(E[i].se.fi)]=car(E[i].se.se);
isi.pb(E[i].se);
}
}
// h2=h1;
cout<<h1<<" "<<h2<<"\n";
for(i=0;i<(n-1);i++)
cout<<isi[i].fi<<" "<<isi[i].se<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
636 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
19 |
Incorrect |
7 ms |
656 KB |
Output isn't correct |
20 |
Incorrect |
7 ms |
636 KB |
Output isn't correct |