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: 65ms
Memory: 3296kB
Author: 2018212212131
In contest: 1261

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=135000;
int fa[maxn];
long long num[maxn];
int find(int x){
	return x==fa[x]?fa[x]:fa[x]=find(fa[x]);
}
void baba(int x,int y){
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy){
	fa[max(fx,fy)]=min(fx,fy);
	num[min(fx,fy)]+=num[max(fx,fy)];
	num[min(fx,fy)]++;
}
}
int main(){
	int n,m;
	while(~scanf("%d%d",&n,&m)){
		long long t=0;
		if(m==0){
			printf("%d\n",n);
			continue;
		}
		for(int i=1;i<=n;i++){
			fa[i]=i;
			num[i]=0;
		}
		for(int i=1;i<=m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			baba(b,a);
		}

		for(int i=1;i<=n;i++){
			t=max(t,num[i]);
		}
//		long long  cnt=0;
//		for(int i=1;i<=n;i++){
//			cnt=0;
//			if(f[i]==i)
//			for(int j=1;j<=n;j++)
//			if(fa[j]==i) cnt++;
//			t=max(cnt,t);
//		}
		printf("%lld\n",t+1);
	}
	return 0;
}