# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
125674 | faustaadp | 시간이 돈 (balkan11_timeismoney) | C++17 | 7 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |