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

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int MAXN = 2e5+5;
int pa[MAXN];
map<int,int>mp;
map<int, int>::iterator it;
int find(int a)
{
	if(pa[a] == a) return a;
	else return pa[a] = find(pa[a]);
}
void combine(int a, int b)
{
	int fa = find(a);
	int fb = find(b);
	if(fa!=fb)
	{
		pa[fa] = fb;
	}
}
int main()
{
	int n, m;
	while(~scanf("%d %d", &n, &m))
	{
		mp.clear();
		for(int i=1;i<=n;i++)
			pa[i] = i;
		for(int i=1;i<=m;i++)
		{
			int u, v;
			scanf("%d %d", &u, &v);
			combine(u, v);
		}
		int ans = 0, maxx = 0;
		for(int i=1;i<=n;i++)
		{
			mp[find(i)]++;
		}
		for(it = mp.begin();it!=mp.end();it++)
		{
			if(it->second > maxx)maxx = it->second;
		}
		printf("%d\n",maxx);
	}
	return 0;
}