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: 187ms
Memory: 5540kB
Author: 2018212212048
In contest: 1261

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
using namespace std;
const int maxn=200010;
const int TNF=0x3f3f3f;
int n,m;
int f[maxn];
map<int,int>mp;
void init(){
	for(int i=1;i<=n;i++){
		f[i]=i;
	}
}

int findf(int x){
	return f[x]==x?f[x]:f[x]=findf(f[x]);
}

int merge(int x,int y){
	if(findf(x)!=findf(y)) f[findf(y)]=findf(x);
}

int main(){
	int a,b;
	while(scanf("%d %d",&n,&m)!=EOF){
		init();
		for(int i=1;i<=m;i++){
			scanf("%d %d",&a,&b);
			merge(a,b);
		}
		int cnt=0;
		int max=0;
		for(int i=1;i<=n;i++){
			mp[findf(i)]++;
			if(mp[findf(i)]>max) max=mp[findf(i)];
		}
		printf("%d\n",max);
		mp.clear();
	}
}