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

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define inf 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define MAXN 100010
#define ll long long
const ll mod=(ll)1e9+7;
int n,m;
int p[MAXN],w[MAXN],ans;
int find(int x)
{
	return p[x]==x?x:p[x]=find(p[x]);
}

void join(int x,int y)
{
	int a=find(x),b=find(y);
	if(a!=b)
	{
		p[b]=a;
		w[a]+=w[b];
		ans=max(ans,w[a]);
	}
}

int main()
{
	int u,v;
	while(~scanf("%d%d",&n,&m))
	{
		ans=0;
		for(int i=1;i<=n;++i)
		{
			w[i]=1;
			p[i]=i;
		}
		while(m--)
		{
			scanf("%d%d",&u,&v);
			join(u,v);
		}
		printf("%d\n",ans);
	}
}