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: 51ms
Memory: 2652kB
Author: 2018212212161
In contest: 1261

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=2e5+10;
int a[maxn]={0};
int vis[maxn];
int find(int x)
{
	return a[x]==x?x:a[x]=find(a[x]);
}
void baba(int x,int y)
{
	int pa=find(x),pb=find(y);
	a[pa]=pb;
}
int main()
{
	int n,m;
	while(~scanf("%d %d",&n,&m))
	{
		memset(vis,0,sizeof(vis));
		for(int i=1;i<=n;i++)
		{
			a[i]=i;
		}
		while(m--)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			baba(x,y);
		}
		for(int i=1;i<=n;i++)
		{
			find(i);
	//		printf(" %d %d\n",i,a[i]);
			vis[a[i]]++;
		}
		int maxx=0;
		for(int i=1;i<=n;i++)
			maxx=max(maxx,vis[i]);
		printf("%d\n",maxx);
	}
}