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: 61ms
Memory: 3276kB
Author: 2018212212064
In contest: 1261

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <iostream>
using namespace std;
const int maxn=int(1e5+10);
struct node
{
	int fa;
	long long w;
}f[maxn];

int find(int x)
{
	return x==f[x].fa?x:f[x].fa=find(f[x].fa);
}
void nuio(int u,int v)
{
	int fu=find(u),fv=find(v);
	if(fu==fv)return ;
	f[fu].fa=f[fv].fa;
	f[fv].w+=f[fu].w;
}

int main()
{
	int n,m,u,v;
	while(~scanf("%d%d",&n,&m))
	{
		for(int i=1;i<=n;++i)
		{f[i].fa=i;f[i].w=1;}
		for(int i=0;i<m;++i)
		{
			scanf("%d%d",&u,&v);
			nuio(u,v);
		}
		long long maxs=0;
		for(int i=1;i<=n;++i)
			if(f[i].fa==i&&f[i].w>maxs)maxs=f[i].w;
		printf("%lld\n",maxs);
	}
}