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: 47ms
Memory: 2492kB
Author: 2017212212098
In contest: 1261

#include "iostream"
#include "set"
using namespace std;
int fa[100005];
int b[100005];
int n,m;
int u,v;

void init(){
	for(int i=0;i<=n;i++){
		fa[i] = i;
		b[i] = 0;
	}
}
int find(int x){
	return x==fa[x]?x:fa[x] = find(fa[x]);
}
void mix(int x,int y){
	int fx = find(x);
	int fy = find(y);
	if(fx!=fy)
		fa[fx] = fy;
}
int main(){
	while(~scanf("%d%d",&n,&m)){
		init();
		for(int i =0;i<m;i++){
			scanf("%d%d",&u,&v);
			mix(u,v);
		}
		int maxx=0;
		for(int i=1;i<=n;i++){
			b[find(i)]++;
		}
		for(int i=1;i<=n;i++){
			if(maxx<b[i])
				maxx = b[i];
		}
		printf("%d\n",maxx);
	}
}