Result: Accepted
Time: 57ms
Memory: 2492kB
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#define MAXN 100005
using namespace std;
typedef long long ll;
int n,m;
int fa[MAXN];
int num[MAXN];
void init(){
for(int i=1;i<=n;i++)
{
fa[i]=i;
num[i]=0;
}
}
int find(int x)
{
return x==fa[x]?x:fa[x]=find(fa[x]);
}
void mix(int x,int y)
{
int fx=find(x),fy=find(y);
fa[fx]=fy;
}
int main()
{
int a,b;
while(scanf("%d%d",&n,&m)!=EOF)
{
init();
while(m--)
{
scanf("%d%d",&a,&b);
mix(a,b);
}
for(int i=1;i<=n;i++)
num[find(i)]++;
int maxx=0;
for(int i=1;i<=n;i++)
maxx=max(maxx,num[i]);
printf("%d\n",maxx);
}
return 0;
}