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: 48ms
Memory: 2376kB
Author: 2018212212175
In contest: 1261

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=100005;
int fa[maxn];
int find(int x)
{
	//return x==fa[x]?fa[x]:fa[x]=find(fa[x]);
	if(x==fa[x])
	{
		return fa[x];
	}
	else
	{
		return fa[x]=find(fa[x]);
	}
}

void baba(int x,int y)
{
	int fx=find(x),fy=find(y);
	fa[fx]=fy;
}

int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		int z;
		int vis[maxn]={0};
		int p=0;
		for(int i=1;i<=n;i++)
		{
			fa[i]=i;
		}
		for(int i=1;i<=m;i++)
		{
			int a,b;
			scanf("%d%d",&a,&b);
			baba(a,b);
		}
		for(int i=1;i<=n;i++)
		{
			z=find(i);
			vis[z]++;
			
		}
		int maxx=0;
		for(int i=1;i<=n;i++)
		{
			maxx=max(maxx,vis[i]);
		}
		printf("%d\n",maxx);
	}
	return 0;
}