Result: Accepted
Time: 78ms
Memory: 2888kB
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
const int maxn=1e5+5;
int fa[maxn];
int num[maxn];
int N[maxn];
int get(int x)
{
if(x==fa[x])return x;
return fa[x]=get(fa[x]);
}
void merge(int x,int y)
{
fa[get(x)]=get(y);
}
int main()
{
int n,m,u,v;
while(~scanf("%d%d",&n,&m))
{
memset(num,0,sizeof(num));
for(int i=1;i<=n;++i)
{
fa[i]=i;
}
int t=1;
if(n==0)printf("0\n");
else
{
while(m--)
{
scanf("%d%d",&u,&v);
merge(u,v);
}
for(int i=1;i<=n;++i)
{
num[get(i)]++;
}
sort(num+1,num+n+1);
printf("%d\n",num[n]);
}
}
return 0;
}