Start: Feb, 21, 2019 12:00:00
2018-2019 ACM集训队冬季集训第二次考核
End: Feb, 21, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 78ms
Memory: 2888kB
Author: 2018212212154
In contest: 1261

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
const int maxn=1e5+5;
int fa[maxn];
int num[maxn];
int N[maxn];
int get(int x)
{
	if(x==fa[x])return x;
	return fa[x]=get(fa[x]);
}
void merge(int x,int y)
{
	fa[get(x)]=get(y);
}
int main()
{
	int n,m,u,v;
	while(~scanf("%d%d",&n,&m))
	{
		memset(num,0,sizeof(num));
		for(int i=1;i<=n;++i)
		{
			fa[i]=i;
		}
		int t=1;
		if(n==0)printf("0\n");
		else
		{
			while(m--)
			{
				scanf("%d%d",&u,&v);
				merge(u,v); 
			}
			for(int i=1;i<=n;++i)
			{
				num[get(i)]++;
			}
			sort(num+1,num+n+1);
			printf("%d\n",num[n]);
		}
	}
	return 0;
}