Nyoj 790 The More,the Better[基础并查集]
来源:互联网 发布:淘宝网怎么盈利 编辑:程序博客网 时间:2024/06/08 10:02
题目链接:气点
#include<stdio.h>#define N 1005int father[N],rank[N];void Init(){ for(int i=1;i<=N;i++) { father[i]=i; rank[i]=1; }}int Find_Father(int x){ if(x!=father[x]) father[x]=Find_Father(father[x]); return father[x];}void Union(int a,int b){ int x=Find_Father(a); int y=Find_Father(b); if(x==y) return; if(rank[x]>rank[y]) { rank[x]+=rank[y]; father[y]=x; } else { rank[y]+=rank[x]; father[x]=y; }}int main(){ int n; while(~scanf("%d",&n)) { Init(); int a,b; for(int i=1;i<=n;i++) { scanf("%d%d",&a,&b); Union(a,b); } int MAX=0; for(int i=1;i<=N;i++) if(rank[i]>MAX) MAX=rank[i]; printf("%d\n",MAX); }}/* 小小的模板*/#define N ?int father[N],rank[N];void Init(){ for(int i=1;i<=N;i++) father[i]=i,rank[i]=1;}int Find_Father(x){ if(x!=father[x]) father[x]=Find_Father(father[x]); return father[x];}void Union(int a,int b){ int x=Find_Father(a); int y=Find_Father(b); if(x==y) return; if(rank[x]>rank[y]) { father[y]=x; rank[x]+=rank[y]; } else { father[x]=y; rank[y]+=rank[x]; }}
- Nyoj 790 The More,the Better[基础并查集]
- hdu 1856 More is better(并查集基础)
- 1856-More is better-基础并查集
- HDU 1856 More is better(基础并查集)
- HDU 1856 More is better 基础并查集★
- hdu 1856 More is better 基础并查集★
- The more, The Better
- The more, The Better
- The more, The Better
- More is better hdu1856 并查集
- hdu1856 ,More is better,并查集
- 并查集C - More is better
- HDOJ1856 More is better 【并查集】
- Hdu1856 - More is better - 并查集
- HDU1856 More is better 并查集
- More is better(并查集)
- 并查集 HDOJ1856 More is better
- HDU1856 More is better 并查集
- SVN服务器搭建和使用(四)Svn 设置 修改 日志
- Jquery 实现 “下次自动登录” 记住用户名密码功能
- 2013年9月25日星期三(demo5_2点法式平面)
- EclipseRCP开发3-建立自定义菜单
- javascript面向对象(this)
- Nyoj 790 The More,the Better[基础并查集]
- ImagePreviewd.js 选择图片预览遇到的问题
- ios设计模式读书笔记----Abstract Factory(抽象工厂)
- ios 画图总结
- ant.xml 详解
- 4.2E2
- 登录退出窗口
- hdu 4750 Count The Pairs (思维+并查集+离散化+二分查找)
- HDOJ_杭电1234_开门人和关门人,又是字符串考察题目