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: 51ms
Memory: 1872kB
Author: 2017212212172
In contest: 1261


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long LL;
int father[100100];
int n, m;
int find(int x) {
	if (x == father[x]) return x;
	else return father[x] = find(father[x]);
}
void unio(int a, int b) {
	int x1 = find(a);
	int y1 = find(b);
	if (x1 != y1) {
		father[x1] = y1;
	}
}
void init() {
	for (int i = 0; i <= n; i++) {
		father[i] = i;
	}
}
int bn[100100];
int main(void) {
	while (scanf("%d%d", &n, &m) != EOF) {
		init();
		memset(bn, 0, sizeof(bn));
		for (int i = 0; i < m; i++) {
			int a, b;
			scanf("%d%d", &a, &b);
			unio(a, b);
		}
		for (int i = 1; i <= n; i++) {
			bn[find(i)]++;
		}
		int maxx = -1;
		for (int i = 1; i <= n; i++) {
			maxx = max(bn[i], maxx);
		}
		printf("%d\n", maxx);
	}
	return 0;
}