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: 142ms
Memory: 5540kB
Author: 2017212212183
In contest: 1261

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<iostream>
#include<vector>
#include<map>

using namespace std;
const int maxn=2e5+5;
int fa[maxn];
map<int,int>mp;

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(){
	int n,m;
	while(~scanf("%d%d",&n,&m)){
		mp.clear();
		for(int i=1;i<=n;i++){
			fa[i]=i;
		}
		while(m--){
			int x,y;
			scanf("%d%d",&x,&y);
			mix(x,y);
		}
		int ans=0;
		for(int i=1;i<=n;i++){
			//printf("*%d %d\n",i,find(i));
			int f=find(i);
			mp[f]++;
			ans=max(ans,mp[f]);
		}
		printf("%d\n",ans);
	}
}