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: 62ms
Memory: 2888kB
Author: 2018212212127
In contest: 1261

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn],fa[maxn],f[maxn];
int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
void add(int x,int y){
	int fx=find(x),fy=find(y);
	fa[fx]=fy;
}
int main(){
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		for(int i=1;i<=n;i++) fa[i]=i;
		for(int i=0;i<m;i++){
			int k,l;
			scanf("%d %d",&k,&l);
			add(k,l);
		}
		memset(f,0,sizeof f);
		for(int i=1;i<=n;i++){
			f[find(i)]++;
		}
		sort(f+1,f+n+1);
		printf("%d\n",f[n]);
	}
}