Result: Accepted
Time: 48ms
Memory: 2376kB
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=100005;
int fa[maxn];
int find(int x)
{
//return x==fa[x]?fa[x]:fa[x]=find(fa[x]);
if(x==fa[x])
{
return fa[x];
}
else
{
return fa[x]=find(fa[x]);
}
}
void baba(int x,int y)
{
int fx=find(x),fy=find(y);
fa[fx]=fy;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
int z;
int vis[maxn]={0};
int p=0;
for(int i=1;i<=n;i++)
{
fa[i]=i;
}
for(int i=1;i<=m;i++)
{
int a,b;
scanf("%d%d",&a,&b);
baba(a,b);
}
for(int i=1;i<=n;i++)
{
z=find(i);
vis[z]++;
}
int maxx=0;
for(int i=1;i<=n;i++)
{
maxx=max(maxx,vis[i]);
}
printf("%d\n",maxx);
}
return 0;
}