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: 49ms
Memory: 3276kB
Author: 2017212212065
In contest: 1261

#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int fa[200002], num[200002];
int find(int x){
	return fa[x] == x? x:fa[x] = find(fa[x]);
}
void mix(int x, int y){
	fa[find(x)] = find(y);
}
int main(void){
	int a, b, c, d, i, ans;
	while(scanf("%d %d",&a,&b)!=EOF){
		ans = -1;
		for(i = 1;i <= a;i++){
			fa[i] = i;
			num[i] = 0;
		}
		while(b--){
			scanf("%d %d",&c,&d);
			mix(c,d);
		}
		for(i = 1;i <= a;i++){
			num[find(i)]++;
		}
		for(i = 1;i <= a;i++){
			ans = max(ans,num[i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}