标签:des style blog class code java
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; struct node { int num,root; }tree[10000005]; int find(int x) { return x==tree[x].root?x:tree[x].root=find(tree[x].root); } void init() { for (int i=0;i<=10000001;i++) { tree[i].num=0; tree[i].root=i; } } int main() { int n,x,y,maxn; while (scanf("%d",&n)!=EOF) { init(); maxn=0; for (int i=0;i<n;i++) { scanf("%d%d",&x,&y); maxn=max(maxn,x); maxn=max(maxn,y); x=find(x); y=find(y); if (x!=y) tree[x].root=y; } int ans=0; for (int i=0;i<=maxn;i++) { tree[find(i)].num++; if (ans<tree[find(i)].num) ans=tree[find(i)].num; } printf("%d\n",ans); } return 0; }
hdu 1856 More is better,布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/chensunrise/p/3719757.html