Result: Accepted
Time: 53ms
Memory: 4216kB
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=200010;
long long a[maxn];
int n,m;
int fa[maxn];
int bb[maxn];
int find(int n)
{
return fa[n]==n?fa[n]:fa[n]=find(fa[n]);
}
void baba(int x,int y)
{
int fx=find(x),fy=find(y);
fa[fx]=fy;
}
bool same(int a,int b)
{
return fa[a]==fa[b];
}
int main(void)
{
while(scanf("%d %d",&n,&m)!=EOF){
int a,b;
memset(bb,0,sizeof(bb));
for(int i=1;i<=n;++i)
{
fa[i]=i;
}
while(m--)
{
scanf("%d%d",&a,&b);
baba(a,b);
}
for(int i=1;i<=n;++i)
{
fa[i]=find(i);
}
for(int i=1;i<=n;++i)
{
++bb[fa[i]];
}
int result=0;
for(int i=1;i<=n;++i)
{
result=max(bb[i],result);
}
printf("%d\n",result);
}
return 0;
}