#include <stdio.h>
#define max 10000010
int tree[max];
int people[max];
int findroot(int x)
{
if(tree[x]==-1)
return x;
else
{
int tap=findroot(tree[x]);
tree[x]=tap;
return tap;
}
}
int main()
{
int n,a,b;
while(scanf("%d",&n)!=EOF)
{
for (int i = 0; i < max; ++i)
{
tree[i]=-1;
people[i]=1;
}
while(n--)
{
scanf("%d %d",&a,&b);
a =findroot(a);
b =findroot(b);
if(a!=b)
{
tree[a]=b;
people[b]+=people[a];
}
}
int people_max=0;
int index=0;
for (int i = 0; i < max; ++i)
{
if(people[i]>people_max)
{
people_max=people[i];
index=i;
}
}
printf("%d\n",people_max);
}
return 0;
}
/**************************************************************
Problem: 1444
User: cust123
Language: C++
Result: Accepted
Time:880 ms
Memory:79144 kb
****************************************************************/
题目1444:More is better
最新推荐文章于 2020-12-17 23:46:40 发布