Result: Accepted
Time: 60ms
Memory: 2492kB
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <sstream>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pi 3.14159265358979323846264338327
#define E 2.71828182846
#define inf 0x3f3f3f3f
#define maxn 2147493647
const ull mod=1<<64;
const int N=4e4+5,M=1e6+5;
const double inff=1e17;
int fa[100010],num[100010],ans;
int wsydd(int x)
{
int t=x;
while(fa[t]!=t)
t=fa[t];
while(fa[x]!=t)
{
int tmp=fa[x];
fa[x]=t;
x=tmp;
}
return t;
}
void wsnbb(int x,int y)
{
int fx=wsydd(x),
fy=wsydd(y);
if(fx!=fy)
{
num[fy]+=num[fx];
ans=max(num[fy],ans);
fa[fx]=fy;
}
}
int main()
{
int n,m;
while (scanf("%d%d",&n,&m)!=EOF)
{
ans=1;
for(int i=1;i<=n;i++)
fa[i]=i,num[i]=1;
for(int i=1;i<=m;i++)
{
int u,v;
scanf("%d%d",&u,&v);
wsnbb(u,v);
}
printf("%d\n",ans);
}
}