Result: Accepted
Time: 68ms
Memory: 2492kB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
using namespace std;
//bool vis[1000005];
int pre[100005];
int n,i,j,m;
void init()
{
for(i=1;i<=n;i++) pre[i]=i;
}
int get(int x)
{
if(x==pre[x]) return x;
return pre[x]=get(pre[x]);
}
void join(int x,int y)
{
pre[get(x)]=get(y);
}
bool same(int x,int y)
{
return get(x)==get(y);
}
int ve[100005];
int main()
{
int a,b;
while(scanf("%d %d",&n,&m)!=EOF)
{
init();
memset(ve,0,sizeof(ve));
while(m--)
{
scanf("%d %d",&a,&b);
join(a,b);
}
for(i=1;i<=n;i++)
{
int ff=get(i);
ve[ff]++;
}
int maxa=1;
for(i=1;i<=n;i++)
{
maxa=max(maxa,ve[i]);
}
printf("%d\n",maxa);
}
}