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: 49ms
Memory: 3276kB
Author: 2017212212165
In contest: 1261

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<math.h>
#include<vector>
#include<stack>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<stdio.h>
#include<functional>
#include<time.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 2e5 + 10;
const ll mode = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846264338327950;
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
template <class T> inline T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }

int n,m;
int pre[maxn];
int js[maxn];
int find1(int x)
{
	int r=x;
	while(pre[r]!=r)
		r=pre[r];
	int i=x;int j;
	while(i!=r)
	{
		j=pre[i];
		pre[i]=r;
		i=j;
	}
	return r;
}

void join(int x,int y)
{
	int fx=find1(x),fy=find1(y);
	if(fx!=fy)
	{
		pre[fx]=fy;
		js[fy]+=js[fx];
	}
}

void init()
{
	for(int i=1;i<=n;i++)
	{
		pre[i]=i;
		js[i]=1;
	}
}
	

int main()
{
	while(~scanf("%d %d",&n,&m))
	{
		init();
		int a,b;
		for(int i=0;i<m;i++)
		{
			scanf("%d %d",&a,&b);
			join(a,b);
		}

		int ans=0;
		for(int i=1;i<=n;i++)
		{
			if(pre[i]==i&&js[i]>ans)
				ans=js[i];
		}

		printf("%d\n",ans);

	}

	return 0;
}