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: 67ms
Memory: 2496kB
Author: Hujia
In contest: 1261

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int maxn=100100;
int n,m,f[maxn],u,v,cnt[maxn];
int find(int u){
	return f[u]==-1?u:f[u]=find(f[u]);
}
void merge (int u, int v){
	int fu=find(u),fv=find(v);
	if(fu!=fv)
		f[fu]=fv;
}
int main()
{
	while(~scanf("%d%d",&n,&m)){
		memset(f,-1,sizeof f);
		memset(cnt,0,sizeof cnt);
		for(int i=0;i<m;++i){
			scanf("%d%d",&u,&v);
			merge(u,v);
		}
		for(int i=1;i<=n;++i){
			int fv=find(i);
			++cnt[fv];
		}
		cout<<*max_element(cnt+1,cnt+1+n)<<endl;
	}
}