Start: Feb, 21, 2019 12:00:00
2018-2019 ACM集训队冬季集训第二次考核
End: Feb, 21, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 52ms
Memory: 2492kB
Author: 2017212212069
In contest: 1261

#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);
	}
}