Hud 2120 Ice_cream's world I[并查集]
来源:互联网 发布:mysql触发器的触发语句 编辑:程序博客网 时间:2024/05/01 21:07
题目链接:点击打开链接
该题就是判环个数。
#include<stdio.h>const int N=1005;int n,m,father[N],Number;void Init(){ for(int i=0;i<=n;i++) father[i]=i; Number=0;}int find(int x){ if(x!=father[x]) father[x]=find(father[x]); return father[x];}void Uinon(int x,int y){ int a=find(x); int b=find(y); if(a!=b) father[a]=b; else Number++;//判环个数,要了解这个环的意思.}int main(){ while(~scanf("%d%d",&n,&m)) { Init(); int a,b; for(int i=1;i<=m;i++) { scanf("%d%d",&a,&b); Uinon(a,b); } printf("%d\n",Number); }}
- Hud 2120 Ice_cream's world I[并查集]
- HDU 2120 Ice_cream's world I(并查集)
- HDOJ 2120 Ice_cream's world I(并查集)
- HD 2120 Ice_cream's world I 【并查集】
- HDOJ 2120 Ice_cream's world I (并查集)
- hdu 2120 Ice_cream's world I 并查集
- HDU 2120 Ice_cream's world I 并查集
- HDOJ 2120 Ice_cream's world I(并查集)
- HDU-2120-Ice_cream's world I【并查集】
- hdoj2120 Ice_cream's world I【并查集】
- Ice_cream's world I hdu 2120 并查集判断环
- HDOJ题目2120 Ice_cream's world I(并查集)
- hdu 2120 Ice_cream's world I(判断是否有环,简单的并查集)
- hdoj 2120 Ice_cream's world I 【并查集判断成环数】
- HDOJ 2120 Ice_cream's world I(并查集判断成环)
- HDU 2120--Ice_cream's world I【并查集, 判断环的个数】
- hdu杭电2120 Ice_cream's world I【并查集】
- HDU 2120--Ice_cream's world I【并查集, 判断环的个数】
- android特效集锦系列之十 仿新浪微博TabHost菜单
- framework中写个java文件,读取手机底层文件数据,提供接口,返回值给上层应用
- 保存yum下载的rpm包
- AS3 TimerManager
- android特效集锦系列总结帖一
- Hud 2120 Ice_cream's world I[并查集]
- C++构造函数和拷贝构造函数详解
- 用户注销时跳出iframe框架的问题
- 用数据管理过程(2)——通过经验值管理项目
- shell - sed用法
- SQL Anywhere 12 数据库编码更改 - 从ASCII编码改为UTF-8
- sqlconnection连接池
- TFS - 删除Test Suite 要小心
- 控制台生成DLL文件的方法