HDU 4738 Caocao's Bridges(Tarjan)】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4738 题目大意:给一些点,用一些边把这些点相连,每一条边上有一个权值.现在要你破坏任意一个边(要付出相应边权值的代价),使得至少有两个连通块.输出最小代价值. 算法思路:这题坑多,要考虑仔细: 1.图是边双连通图,就做不到删除一边得到两个连通块,这种情况输出-1. 2.图是连通但不边双联通,就用tarjan找出桥中权值最小的,这里有个巨坑,如果桥最小的权值为0,这时根据题意,要输出1而不是0(看看题…
题目链接 #include <iostream> #include <cstring> #include <cstdio> #include <queue> #include <cstdlib> using namespace std; #define N 1001 #define M 20000001 #define INF 0x3f3f3f3f struct node { int u,v,next; }edge[M]; int first[N…
题目链接: Hdu 4738 Caocao's Bridges 题目描述: 有n个岛屿,m个桥,问是否可以去掉一个花费最小的桥,使得岛屿边的不连通? 解题思路: 去掉一个边使得岛屿不连通,那么去掉的这个边一定是一个桥,所以我们只需要求出来所有的桥,然后比较每个桥的花费,选取最小的那个就好. 看起来很简单的样子哦!但是这个题目有很多的细节: A:题目中有重边,以后写Tarjan还是清一色判断重边吧.(除非题目特别要求) B:m个桥有可能连通不了这n个桥,这个时候不需要花费. C:当最小花费桥的花费…
Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3992    Accepted Submission(s): 1250 Problem Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi.…
 Caocao's Bridges Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4738 Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn't give up. Caocao's army s…
Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 194    Accepted Submission(s): 89 Problem Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But…
Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5050    Accepted Submission(s): 1584 Problem Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi.…
Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1231    Accepted Submission(s): 478 Problem Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. B…
Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn't give up. Caocao's army still was not good…
<题目链接> 题目大意: 曹操在长江上建立了一些点,点之间有一些边连着.如果这些点构成的无向图变成了连通图,那么曹操就无敌了.周瑜为了防止曹操变得无敌,就打算去摧毁连接曹操的点的桥.但是诸葛亮把所有炸弹都带走了,只留下一枚给周瑜.所以周瑜只能炸一条桥. 题目给出n,m.表示有n个点,m条桥. 接下来的m行每行给出a,b,c,表示a点和b点之间有一条桥,而且曹操派了c个人去守卫这条桥. 现在问周瑜最少派多少人去炸桥. 如果无法使曹操的点成为多个连通图,则输出-1. 解题思路: 就是用Tarjan…