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: 68ms
Memory: 1876kB
Author: 2018212212041
In contest: 1261

#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int fa[100001],c[100001];
int find(int x) {
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int merge(int x,int y) {
	if(find(fa[x])!=find(fa[y]))fa[find(fa[x])]=find(fa[y]);
}
int main() {
	int n,m;
	int a,b;
	while(scanf("%d %d",&n,&m)!=EOF) {
		for(int i=1; i<=n; i++)fa[i]=i;
		for(int i=1; i<=m; i++) {
			scanf("%d %d",&a,&b);
			merge(a,b);
		}
		memset(c,0,sizeof c);
		for(int i=1; i<=n; i++) {
			c[find(fa[i])]++;
		}
		sort(c+1,c+n+1);printf("%d\n",c[n]);
	}
}