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

#include<iostream>
#include<cstring>
using namespace std;
int n,m;
int u,v;
int sum=0;
int fa[100000];
int b[100000];
int get(int x)
{
	if(x==fa[x]) return x;
	return fa[x]=get(fa[x]);
}
void join(int x,int y)
{
	fa[get(x)]=get(y);
}
int main()
{
	while(cin>>n>>m)
	{
		sum=0;
		memset(b,0,sizeof b);
		sum=0;
		for(int i=1;i<=n;i++)	
		fa[i]=i;
		for(int i=1;i<=m;i++)
		{
			cin>>u>>v;
			join(u,v);
		}
		for(int i=1;i<=n;i++)
		{
			b[get(i)]++;
		}
		for(int i=1;i<=n;i++)
		{
			sum=max(sum,b[i]);
		}
		cout<<sum<<endl;
	}
}