Result: Accepted
Time: 130ms
Memory: 5540kB
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int MAXN = 2e5+5;
int pa[MAXN];
map<int,int>mp;
map<int, int>::iterator it;
int find(int a)
{
if(pa[a] == a) return a;
else return pa[a] = find(pa[a]);
}
void combine(int a, int b)
{
int fa = find(a);
int fb = find(b);
if(fa!=fb)
{
pa[fa] = fb;
}
}
int main()
{
int n, m;
while(~scanf("%d %d", &n, &m))
{
mp.clear();
for(int i=1;i<=n;i++)
pa[i] = i;
for(int i=1;i<=m;i++)
{
int u, v;
scanf("%d %d", &u, &v);
combine(u, v);
}
int ans = 0, maxx = 0;
for(int i=1;i<=n;i++)
{
mp[find(i)]++;
}
for(it = mp.begin();it!=mp.end();it++)
{
if(it->second > maxx)maxx = it->second;
}
printf("%d\n",maxx);
}
return 0;
}