# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125674 | faustaadp | timeismoney (balkan11_timeismoney) | C++17 | 7 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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));
}
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;
h2+=E[i].fi.se;
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";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |