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: 80ms
Memory: 2372kB
Author: 2018212212307
In contest: 1261

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =1e5+5;
int fa[maxn];
int n,m;
int ans=0;
int get(int x)
{
	if(x==fa[x])return x;
	return fa[x]=get(fa[x]);
}
void baba(int x,int y)
{
	fa[get(x)]=get(y);
}
int main()
{
	while(cin>>n>>m)
	{
		ans=0;
		for(int i=1;i<=n;i++)fa[i]=i;
		for(int i=1;i<=m;i++)
		{
			int u,v;
			cin>>v>>u;
			if(v>u)swap(v,u);
			baba(v,u);
		}
		int x[maxn]={0};
		for(int i=1;i<=n;i++)
		{
			baba(i,fa[i]);
		}
		for(int i=1;i<=n;i++)x[fa[i]]++;
		for(int i=1;i<=n;i++)ans=max(ans,x[i]);
		//for(int i=1;i<=n;i++)printf("%d %d\n",i,fa[i]);
		printf("%d\n",ans);
	}
}