Codeup 并查集之问题 D: More is better_codeup problem d: more is better-CSDN博客

网站介绍:文章浏览阅读258次。分析本题要求我们算出每个集合中的元素个数,然后输出元素个数的最大值元素个数的计算,我采用的思路是:noc数组记录结点拥有的孩子结点数遍历每个结点,找到他的根结点,将noc【ff( i )】递增每次递增完判别一下是否大于max,是则更新,最后输出max即可#include<iostream>using namespace std;int father[100005];int noc[100005];void init(){ for(int i=1;i<10000_codeup problem d: more is better