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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10 ;
int fa[maxn] ;
int ggg[maxn] ;
int find(int x)
{
	return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);
}
void unit(int x , int y)
{
	int fx = find(x) , fy = find(y) ;
	fa[fx] = fy ;

}
void init(int n)
{
	for(int i = 1 ; i <= n ; ++ i)
		fa[i] = i ;
	memset(ggg,0,sizeof ggg) ;
}
int main(int argc, char const *argv[])
{
	int n , m ;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		int cnt = 0 ;
		init(n) ;
		while(m --)
		{
			int x , y ;
			scanf("%d %d",&x,&y) ;
			unit(x , y) ;
		}
		for(int i = 1 ; i <= n ; ++ i)
		{
			ggg[find(i)] ++ ;
		}
		for(int i = 1 ; i <= n ; ++ i)
		{
			cnt = max(ggg[i] , cnt) ;
		}
		printf("%d\n",cnt) ;
	}
	return 0;
}