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: 53ms
Memory: 4216kB
Author: 2018212212125
In contest: 1261

#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=200010;
long long a[maxn];
int n,m;
int fa[maxn];
int bb[maxn];
int find(int n)
{
	return fa[n]==n?fa[n]:fa[n]=find(fa[n]);
}
void baba(int x,int y)
{
	int fx=find(x),fy=find(y);
	fa[fx]=fy;
}
bool same(int a,int b)
{
return fa[a]==fa[b];
}
int main(void)
{
	while(scanf("%d %d",&n,&m)!=EOF){
	 int a,b;
	 memset(bb,0,sizeof(bb));
	 for(int i=1;i<=n;++i)
	 {
		fa[i]=i;
	 }
	 while(m--)
	 {
	 	scanf("%d%d",&a,&b);
		baba(a,b);
	 }
	 for(int i=1;i<=n;++i)
	 {
		fa[i]=find(i);
	 }
	 for(int i=1;i<=n;++i)
	 {
		 ++bb[fa[i]];
	 }
	 int result=0;
	 for(int i=1;i<=n;++i)
	 {
		 result=max(bb[i],result);
	 }
	 printf("%d\n",result);
	}
	return 0;
}