Result: Accepted
Time: 47ms
Memory: 2492kB
#include "iostream"
#include "set"
using namespace std;
int fa[100005];
int b[100005];
int n,m;
int u,v;
void init(){
for(int i=0;i<=n;i++){
fa[i] = i;
b[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);
int fy = find(y);
if(fx!=fy)
fa[fx] = fy;
}
int main(){
while(~scanf("%d%d",&n,&m)){
init();
for(int i =0;i<m;i++){
scanf("%d%d",&u,&v);
mix(u,v);
}
int maxx=0;
for(int i=1;i<=n;i++){
b[find(i)]++;
}
for(int i=1;i<=n;i++){
if(maxx<b[i])
maxx = b[i];
}
printf("%d\n",maxx);
}
}