摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1272题目要求有两个条件:1.在给定图中无环 2.给定的图有且仅有有1个连通分支判断环:在输入时判断点a点b是否有相同的根节点,有相同根节点再加一条直接连通的边就有环.判断连通分支数:判断有几个跟节点 if(father[i]==i)View Code 1 #include <iostream> 2 using namespace std; 3 const int MAX = 100000 + 100; 4 int father[MAX]; 5 int rank1[MAX]; ... 阅读全文
posted @ 2012-08-25 17:53 zx雄 阅读(223) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1232题意:不好说,自己看.基本上根据并查集模版写出代码,只是作出简单的调用和在函数Union()中增加了道路数量的计算.View Code 1 #include <iostream> 2 using namespace std; 3 const int MAX = 1000 + 100; 4 int father[MAX]; 5 int rank1[MAX]; 6 int sign[MAX]; 7 int step; 8 void Make_Set(int x)//初始化 9 {10 fathe 阅读全文
posted @ 2012-08-25 16:18 zx雄 阅读(287) 评论(0) 推荐(0) 编辑