Result: Accepted
Time: 51ms
Memory: 2652kB
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=2e5+10;
int a[maxn]={0};
int vis[maxn];
int find(int x)
{
return a[x]==x?x:a[x]=find(a[x]);
}
void baba(int x,int y)
{
int pa=find(x),pb=find(y);
a[pa]=pb;
}
int main()
{
int n,m;
while(~scanf("%d %d",&n,&m))
{
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++)
{
a[i]=i;
}
while(m--)
{
int x,y;
scanf("%d %d",&x,&y);
baba(x,y);
}
for(int i=1;i<=n;i++)
{
find(i);
// printf(" %d %d\n",i,a[i]);
vis[a[i]]++;
}
int maxx=0;
for(int i=1;i<=n;i++)
maxx=max(maxx,vis[i]);
printf("%d\n",maxx);
}
}