Result: Accepted
Time: 68ms
Memory: 1876kB
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int fa[100001],c[100001];
int find(int x) {
return fa[x]==x?x:fa[x]=find(fa[x]);
}
int merge(int x,int y) {
if(find(fa[x])!=find(fa[y]))fa[find(fa[x])]=find(fa[y]);
}
int main() {
int n,m;
int a,b;
while(scanf("%d %d",&n,&m)!=EOF) {
for(int i=1; i<=n; i++)fa[i]=i;
for(int i=1; i<=m; i++) {
scanf("%d %d",&a,&b);
merge(a,b);
}
memset(c,0,sizeof c);
for(int i=1; i<=n; i++) {
c[find(fa[i])]++;
}
sort(c+1,c+n+1);printf("%d\n",c[n]);
}
}