답안 #125671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125671 2019-07-06T07:54:05 Z faustaadp 시간이 돈 (balkan11_timeismoney) C++17
40 / 100
7 ms 632 KB
#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;
			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 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 7 ms 632 KB Output is 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 376 KB Output isn't correct
13 Incorrect 2 ms 248 KB Output isn't correct
14 Incorrect 2 ms 376 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 3 ms 376 KB Output isn't correct
18 Incorrect 3 ms 376 KB Output isn't correct
19 Incorrect 7 ms 632 KB Output isn't correct
20 Incorrect 7 ms 632 KB Output isn't correct