Result: Accepted
Time: 48ms
Memory: 2492kB
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define inf 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define MAXN 100010
#define ll long long
const ll mod=(ll)1e9+7;
int n,m;
int p[MAXN],w[MAXN],ans;
int find(int x)
{
return p[x]==x?x:p[x]=find(p[x]);
}
void join(int x,int y)
{
int a=find(x),b=find(y);
if(a!=b)
{
p[b]=a;
w[a]+=w[b];
ans=max(ans,w[a]);
}
}
int main()
{
int u,v;
while(~scanf("%d%d",&n,&m))
{
ans=0;
for(int i=1;i<=n;++i)
{
w[i]=1;
p[i]=i;
}
while(m--)
{
scanf("%d%d",&u,&v);
join(u,v);
}
printf("%d\n",ans);
}
}