HDU 4005 The war (图论-tarjan)】的更多相关文章

HDU 4005 The war pid=4005" target="_blank" style="">题目链接 题意:给一个连通的无向图.每条边有一个炸掉的代价.如今要建一条边(你不不知道的),然后你要求一个你须要的最少代价,保证无论他建在哪,你都能炸掉使得图不连通 思路:炸肯定要炸桥,所以先双连通缩点,得到一棵树,树边是要炸的,那么找一个最小值的边.从该边的两点出发.走的路径中,把两条包括最小值的路径.的两点连边.形成一个环.这个环就保证了最低代…
The war Problem Description In the war, the intelligence about the enemy is very important. Now, our troop has mastered the situation of the enemy's war zones, and known that these war zones can communicate to each other directly or indirectly throug…
The war Problem Description   In the war, the intelligence about the enemy is very important. Now, our troop has mastered the situation of the enemy's war zones, and known that these war zones can communicate to each other directly or indirectly thro…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4005 In the war, the intelligence about the enemy is very important. Now, our troop has mastered the situation of the enemy's war zones, and known that these war zones can communicate to each other direc…
题意 ​ 给定一张 \(n\) 个点 \(m\) 条边的无向连通图,加入一条边,使得图中权值最小的桥权值最大,如果能使图中没有桥则输出 \(-1\). 思路 ​ 先对原图边双缩点,然后变成了一棵树.在树上加一条边等价于使一条路径上的边都不是桥,那么原题转化为在树上删一条路径,使得最小的边最大.固定一条最小的边之后模拟即可. 代码 #include<bits/stdc++.h> #define FOR(i, x, y) for(int i = (x), i##END = (y); i <=…
题意: 有一个边带权的无向图,敌人可以任意在图中加一条边,然后你可以选择删除任意一条边使得图不连通,费用为被删除的边的权值. 求敌人在最优的情况下,使图不连通的最小费用. 分析: 首先求出边双连通分量,缩点成树. 敌人如果选则树中\(u,v\)节点之间加一条边,则路径\(u \to v\)中所有的边都会变成环. 我们只能考虑删除其他的权值最小的边使图不连通. 从敌人的角度考虑:如果使树中权值最小的边成环,那么我们的费用会增加.在最小边成环的前提下,如果还能使次小边也成环,我们的费用又会增加,以此…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10    Accepted Submission(s): 3 Problem Description There are N bombs needing exploding.Each bomb has three attributes: exploding radius ri,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4738 题目大意:给一些点,用一些边把这些点相连,每一条边上有一个权值.现在要你破坏任意一个边(要付出相应边权值的代价),使得至少有两个连通块.输出最小代价值. 算法思路:这题坑多,要考虑仔细: 1.图是边双连通图,就做不到删除一边得到两个连通块,这种情况输出-1. 2.图是连通但不边双联通,就用tarjan找出桥中权值最小的,这里有个巨坑,如果桥最小的权值为0,这时根据题意,要输出1而不是0(看看题…
Hawk-and-Chicken Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4170    Accepted Submission(s): 1301 Problem Description Kids in kindergarten enjoy playing a game called Hawk-and-Chicken. But t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4005 思路:首先考虑边双连通分量,如果我们将双连通分量中的边删除,显然我们无法得到非连通图,因此要缩点成树,对于树上的边,我们找到权值最小的边,从这条边的两个端点开始深搜,然后找分别一这两个端点为根的子树中第二权值小的边的最小值. http://paste.ubuntu.com/5954870/…