![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
友谊无价
CQUPT的蒟蒻
展开
-
[Aha]擒贼先擒王
题目:详见啊哈算法P200页。就是并查集的裸题。 分析:裸题呀,理解并背下代码。 代码:#include<iostream> #include<cstdio> #include<cstring> using namespace std ;int f[1000]={0},n,m,k,sum;int getf(int x){ if(f[x]==x) return x ; else{原创 2017-03-07 23:45:23 · 222 阅读 · 0 评论 -
[Aha]镖局运镖
题目:详见啊哈算法P212页。 分析:最小生成树-需要结合并查集。 代码:#include<iostream> #include<cstdio> #include<algorithm> using namespace std ;int f[1000]; class edge{ public: int u ; int v ; int w原创 2017-03-09 21:00:49 · 404 阅读 · 0 评论 -
[POJ] 2485 Highways
题目: The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They’re原创 2017-03-11 08:53:17 · 288 阅读 · 0 评论 -
[POJ] 1258 Agri-Net
题目: Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John ordered a hig原创 2017-03-11 08:55:51 · 331 阅读 · 0 评论 -
[HDU] 1879 继续畅通工程
题目: 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 1< N < 100 );随后的 N(N-1)/原创 2017-03-11 09:14:55 · 374 阅读 · 0 评论