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: 71ms
Memory: 4060kB
Author: 2018212212155
In contest: 1261

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int n,m,u,v,i;
int fa[200010],xx[200010],a[200010];
int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
void bing(int x,int y){
	int fx=find(x),fy=find(y);
	fa[fx]=fy;
}
int main(){
	while(scanf("%d %d",&n,&m)!=EOF){
		int t=1;
		memset(a,0,sizeof(a));
		for(i=1;i<=n;i++){
			fa[i]=i;
		}
		for(i=1;i<=m;i++){
			scanf("%d %d",&u,&v);
			bing(v,u);
		}
		for(i=1;i<=n;i++){
			xx[i]=find(i);
		}
		/*for(i=1;i<=n;i++){
			printf("%d ",xx[i]);
		}*/
		sort(xx+1,xx+n+1);
		/*for(i=1;i<=n;i++){
			printf("%d ",xx[i]);
		}*/
		a[1]=1;
		for(i=2;i<=n;i++){
			if(xx[i]!=xx[i-1]){
				t++;
				a[t]=1;
			}
			else	a[t]++;
		}
		sort(a+1,a+t+1);
		printf("%d\n",a[t]);
	}
}