Result: Accepted
Time: 142ms
Memory: 5540kB
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
const int maxn=2e5+5;
int fa[maxn];
map<int,int>mp;
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(){
int n,m;
while(~scanf("%d%d",&n,&m)){
mp.clear();
for(int i=1;i<=n;i++){
fa[i]=i;
}
while(m--){
int x,y;
scanf("%d%d",&x,&y);
mix(x,y);
}
int ans=0;
for(int i=1;i<=n;i++){
//printf("*%d %d\n",i,find(i));
int f=find(i);
mp[f]++;
ans=max(ans,mp[f]);
}
printf("%d\n",ans);
}
}