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: 54ms
Memory: 3276kB
Author: 2017212212217
In contest: 1261

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string.h>
using namespace std;
int fa[200005];
int a[200005];
int find(int x)
{
	if(fa[x]==x)
	{
		return x;
	}
	else
	{
		return fa[x]=find(fa[x]);
	}
}
void merge(int x,int y)
{
	int xx=find(x),yy=find(y);
	if(xx!=yy)
	{
		fa[xx]=yy;
	}
}
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		memset(a,0,sizeof(a));
		for(int i=1;i<=n;i++)
		{
			fa[i]=i;
		}
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			merge(u,v);
		}
		int maxn=0;
		for(int i=1;i<=n;i++)
		{
			a[find(i)]++;
		}
		for(int i=1;i<=n;i++)
		{
			maxn=max(maxn,a[i]);
		}
		printf("%d\n",maxn);
	}
}