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: 151ms
Memory: 5076kB
Author: 2018212212094
In contest: 1261

#include<stdio.h>
#include<map>
const  int maxn=100000+10;
long long p[maxn];
using namespace std;
int find(int x) {
	if(x!=p[x])return p[x]=find(p[x]);
	else return x;
}
void join(int x,int y) {
	if(find(x)!=find(y)) p[find(x)]=find(y);
}
int main() {
	int n,m,res,a,b;
	while(scanf("%d%d",&n,&m)!=EOF) {
		map<int,int>mp;
		res=0;
		mp.clear();
		for (int i=1; i<=n; i++) {
			p[i]=i;
		}
		for (int i=1; i<=m; i++) {
			scanf("%d%d",&a,&b);
			join(a,b);
		}
		for (int i=1; i<=n; i++) {
			mp[find(i)]++;
			res=max(res,mp[find(i)]);
		}
		printf("%d\n",res);
	}
	return 0;
}