Result: Accepted
Time: 52ms
Memory: 2492kB
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
const double INF = 0x777777;
const int maxn = 100010;
int fa[maxn];
int num[maxn];
int find(int x) {
if (x == fa[x]) {
return x;
}
else {
return fa[x] = find(fa[x]);
}
}
void mix(int x, int y) {
int fx = find(x), fy = find(y);
fa[fx] = fy;
}
int main() {
int n, m, u, v;
while (scanf("%d%d", &n, &m) != EOF) {
for (int i = 1; i <= n; i++) {
fa[i] = i;
num[i] = 0;
}
for (int i = 0; i<m; ++i) {
scanf("%d%d", &u, &v);
mix(u, v);
}
for (int i = 1; i <= n; i++) {
num[find(i)]++;
}
int maxx = 0;
for (int i = 1; i <= n; ++i) {
maxx = max(maxx, num[i]);
}
printf("%d\n", maxx);
}
}