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

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int inf = 0x3f3f3f3f;
#define LL long long int
long long  gcd(long long  a, long long  b) { return a == 0 ? b : gcd(b % a, a); }


int F[100005],n,m,num[100005];

int find(int x)
{
	if(F[x]==x)return x;
	else return F[x]=find(F[x]);
}

int main()
{
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		for(int i=1;i<=n;i++)F[i]=i,num[i]=0;
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d %d",&u,&v);
			int t1=find(u);
			int t2=find(v);
			if(t1!=t2)F[t1]=t2;
		}
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			int fx=find(i);
			num[fx]++;
			ans=max(ans,num[fx]);
		}
		printf("%d\n",ans);
	}

}