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: 57ms
Memory: 2492kB
Author: 2017212212283
In contest: 1261

#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <stack>

#define MAXN 100005
using namespace std;
typedef long long ll;

int n,m;
int fa[MAXN];
int num[MAXN];

void init(){
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		num[i]=0;
	}
		
}

int find(int x)
{
	return x==fa[x]?x:fa[x]=find(fa[x]);
}

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

int main()
{
	int a,b;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		init();
		while(m--)
		{
			scanf("%d%d",&a,&b);
			mix(a,b);
		}
		
		for(int i=1;i<=n;i++)
			num[find(i)]++;
		
		int maxx=0;
		for(int i=1;i<=n;i++)
			maxx=max(maxx,num[i]);
		
		printf("%d\n",maxx);
	}
	return 0;
}