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

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
using namespace std;
//bool vis[1000005];
int pre[100005];
int n,i,j,m;
void init()
{
	for(i=1;i<=n;i++) pre[i]=i;
}
int get(int x)
{
	if(x==pre[x]) return x;
	return pre[x]=get(pre[x]);
}
void join(int x,int y)
{
	pre[get(x)]=get(y);
}
bool same(int x,int y)
{
	return get(x)==get(y);
}
int ve[100005];
int main()
{
	int a,b;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		init();
		memset(ve,0,sizeof(ve));
		while(m--)
		{
			scanf("%d %d",&a,&b);
			join(a,b);
		}
		for(i=1;i<=n;i++)
		{
			int ff=get(i);
			ve[ff]++;
		}
		int maxa=1;
		for(i=1;i<=n;i++)
		{
			maxa=max(maxa,ve[i]);
		}
		printf("%d\n",maxa);	
	}
}