Result: Accepted
Time: 75ms
Memory: 3280kB
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
/*
int n;
ll sum[1001];
int main()
{
while(scanf("%d", &n) != EOF)
{
int flag = 1;
ll ans = 0;
for(int i = 1; i <= n; i++)
{
scanf("%lld", &sum[i]);
if(flag)
{
if(sum[i] == 1)
ans++;
else
flag = 0;
}
}
if(flag != 1)
{
if(ans % 2)
cout << "L" << endl;
else
cout << "H" << endl;
}
else
{
if(ans % 2)
cout << "H" << endl;
else
cout << "L" << endl;
}
}
return 0;
}*/
int n, m;
ll sum[maxn];
int fa[maxn];
int flag[maxn];
int find(int x)
{
if(x == fa[x])
return x;
else
return fa[x] = find(fa[x]);
}
int main()
{
while(~scanf("%d %d", &n, &m))
{
for(int i = 1; i <= n; i++)
{
fa[i] = i;
sum[i] = 0;
flag[i] = 0;
}
while(m--)
{
int u, v;
scanf("%d %d", &u, &v);
flag[u] = 1;
flag[v] = 1;
int fx = find(u), fy = find(v);
if(fx != fy)
fa[fx] = fy;
}
ll s = 0;
for(int i = 1; i <= n; i++)
{
if(flag[i] == 0)
continue;
sum[find(i)]++;
}
sort(sum + 1, sum + 1 + n);
cout << sum[n] << endl;
}
return 0;
}