Result: Accepted
Time: 67ms
Memory: 2496kB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int maxn=100100;
int n,m,f[maxn],u,v,cnt[maxn];
int find(int u){
return f[u]==-1?u:f[u]=find(f[u]);
}
void merge (int u, int v){
int fu=find(u),fv=find(v);
if(fu!=fv)
f[fu]=fv;
}
int main()
{
while(~scanf("%d%d",&n,&m)){
memset(f,-1,sizeof f);
memset(cnt,0,sizeof cnt);
for(int i=0;i<m;++i){
scanf("%d%d",&u,&v);
merge(u,v);
}
for(int i=1;i<=n;++i){
int fv=find(i);
++cnt[fv];
}
cout<<*max_element(cnt+1,cnt+1+n)<<endl;
}
}