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: 77ms
Memory: 9524kB
Author: 2018212212255
In contest: 1261

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1000005;
int MAX;
int num[maxn],f[maxn];
int find(int x){
	return x == f[x] ? f[x] : f[x] = find(f[x]);
}
void baba(int x ,int y){
	int fx = find(x),fy = find(y);
	f[fx] = fy;
}
int main(){
	int n,m,a,b;
	while(scanf("%d %d",&n,&m)!=EOF){
		memset(num,0,sizeof(num));
		for(int i = 1; i <= n ; i++){
			f[i] = i;
		}
		MAX = 0;
		for(int i = 1 ; i <= m ; i++){
			scanf("%d %d",&a,&b);
			baba(a,b);
		}
		for(int i = 1 ; i <= n ; i++){
			find(i);
		}
		for(int i = 1 ; i <= n ; i++){
			num[f[i]]++;
			MAX =max(MAX,num[f[i]]);
		}
		printf("%d\n",MAX);
	}
	return 0;
}