家庭房产
解题步骤
①、并查集
将每个家庭都看成一个集合,再统计每个家庭的人数、房产套数、总面积。
②、计算有效数据
对于每个家庭来说
人均房产套数:房产套数/家庭人数
人均房产面积:总面积/家庭人数
③、排名
利用 sort() 函数得出排名。
实现代码
#include<bits/stdc++.h>
using namespace std;
int u[10010], C[10010], S[10010];
bool judge[10010]={
false};
struct node{
int sum_c;
int sum_s;
int min_bh;
int men;
double pj_s;
double pj_c;
}f[10010];
int get_(int x){
if(u[x]==x) return x;
return u[x]=get_(u[x]);
}
bool cmp1(node a, node b){
return a.sum_c>b.sum_c;
}
bool cmp2(n