Result: Accepted
Time: 62ms
Memory: 2888kB
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn],fa[maxn],f[maxn];
int find(int x){
return fa[x]==x?x:fa[x]=find(fa[x]);
}
void add(int x,int y){
int fx=find(x),fy=find(y);
fa[fx]=fy;
}
int main(){
int n,m;
while(~scanf("%d %d",&n,&m)){
for(int i=1;i<=n;i++) fa[i]=i;
for(int i=0;i<m;i++){
int k,l;
scanf("%d %d",&k,&l);
add(k,l);
}
memset(f,0,sizeof f);
for(int i=1;i<=n;i++){
f[find(i)]++;
}
sort(f+1,f+n+1);
printf("%d\n",f[n]);
}
}