답안 #712326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
712326 2023-03-18T14:53:34 Z study 시간이 돈 (balkan11_timeismoney) C++17
40 / 100
6 ms 724 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 201;

int comp[N],siz[N];
int sum=0;
vector<pair<int,int>> ans;

int getComp(int node){
	if (comp[node] != node) comp[node] = getComp(comp[node]);
	return comp[node];
}

bool merge(int a, int b){
	a = getComp(a);
	b = getComp(b);
	if (a != b){
		if (siz[a] < siz[b]) swap(a,b);
		//cout << a << ' ' << b << ' ' << cost << endl;
		siz[a] += siz[b];
		comp[b] = a;
		return true;
	}
	return false;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<tuple<int,int,int>> v;
	for (int i=0; i<m; ++i){
		int x,y,t,c;
		cin >> x >> y >> t >> c;
		v.emplace_back(t,x,y);
	}
	for (int i=0; i<n; ++i){
		siz[i] = 1;
		comp[i] = i;
	}
	sort(v.begin(),v.end());
	for (auto [t,x,y]:v){
		if (merge(x,y)){
			sum += t;
			ans.emplace_back(x,y);
		}
	}
	cout << sum << ' ' << sum << '\n';
	for (auto i:ans) cout << i.first << ' ' << i.second << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 1 ms 340 KB Output isn't correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Incorrect 1 ms 328 KB Output isn't correct
16 Incorrect 1 ms 340 KB Output isn't correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Incorrect 1 ms 340 KB Output isn't correct
19 Incorrect 4 ms 716 KB Output isn't correct
20 Incorrect 6 ms 724 KB Output isn't correct