Result: Accepted
Time: 49ms
Memory: 3276kB
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int fa[200002], num[200002];
int find(int x){
return fa[x] == x? x:fa[x] = find(fa[x]);
}
void mix(int x, int y){
fa[find(x)] = find(y);
}
int main(void){
int a, b, c, d, i, ans;
while(scanf("%d %d",&a,&b)!=EOF){
ans = -1;
for(i = 1;i <= a;i++){
fa[i] = i;
num[i] = 0;
}
while(b--){
scanf("%d %d",&c,&d);
mix(c,d);
}
for(i = 1;i <= a;i++){
num[find(i)]++;
}
for(i = 1;i <= a;i++){
ans = max(ans,num[i]);
}
printf("%d\n",ans);
}
return 0;
}