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: 2017212212271
In contest: 1261

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<string.h>
using namespace std;
const int INF = 0x3f3f3f3f;
#define pi acos(-1.0)
typedef long long ll;
#define esp 1e-7
const int maxn=200000+10;
int n,m;
int pre[maxn];
int cnt[maxn];
int find(int x)
{
	if(x!=pre[x])
		pre[x]=find(pre[x]);
	return pre[x];
}
void merge(int x,int y)
{
	int prex=find(x);
	int prey=find(y);
	if(prex==prey)
		return ;
	pre[prey]=prex;
}
void init()
{
	for(int i=0;i<=n;i++)
	{
		pre[i]=i;
		cnt[i]=0;
	}
}
int main()
{
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		init();
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			merge(u,v);
		}
		for(int i=1;i<=n;i++)
		{
			if(find(i)==pre[i])
			{
				cnt[pre[i]]++;
			}
			//printf("%d ",pre[i]);
		}//printf("\n");
		int maxx=0;
		for(int i=1;i<=n;i++)
		{
			if(cnt[i]>maxx)
				maxx=cnt[i];
		}
		printf("%d\n",maxx);
	}
	//system("pause");
	return 0;
}
/*
8 5
1 3
2 6
1 5
2 7
4 6

*/