poj3114Countries in War(缩点+DIJK)】的更多相关文章

http://poj.org/problem?id=3114 缩点+DIJK 注意缩点之后有重边啊 floyd会TLE #include <iostream> #include<cstring> #include<cstdio> #include<stdlib.h> #include<algorithm> #include<stack> #define N 510 #define M 301000 #define INF 0xffff…
                                Countries in War Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3672   Accepted: 1057 Description In the year 2050, after different attempts of the UN to maintain peace in the world, the third world war b…
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 through the network. We also know…
Countries in War Time Limit: 1000MS Memory Limit: 65536K Description In the year 2050, after different attempts of the UN to maintain peace in the world, the third world war broke out. The importance of industrial, commercial and military secrets obl…
题目链接 题意是说在几个邮局之间传送一份信件,如果出发点和终止点在同一个国家传递,则时间为0,否则让你求花费最少时间,如果不能传到,则输出Nao e possivel entregar a carta.判断邮局是否在同一个国家的依据是发出的信件可以相互到达. 如果直接求最短路则无法判断两个邮局是否在同一个国家,判断两个邮局是否属于同一个国家的标志是在这个国家邮局间可以相互到达,那么这就是强连通了,所以要先缩点判读邮局是否在同一个国家,如果不是,则重新建图,建图的时候要维护好边权,求出最短边权,在…
题目大意: 在一个有向图中,每两点间通信需要一定的时间,但同一个强连通分量里传递信息不用时间,给两点u,v求他们最小的通信时间.   解题过程: 1.首先把强连通分量缩点,然后遍历每一条边来更新两个强联通分量之间的距离.. 2.直接Floyd会超时,应该用dijstra或者spfa做k次最短路.   犯的错误:前向星数组开的太小,一直超时.  …
题意: 有一个边带权的无向图,敌人可以任意在图中加一条边,然后你可以选择删除任意一条边使得图不连通,费用为被删除的边的权值. 求敌人在最优的情况下,使图不连通的最小费用. 分析: 首先求出边双连通分量,缩点成树. 敌人如果选则树中\(u,v\)节点之间加一条边,则路径\(u \to v\)中所有的边都会变成环. 我们只能考虑删除其他的权值最小的边使图不连通. 从敌人的角度考虑:如果使树中权值最小的边成环,那么我们的费用会增加.在最小边成环的前提下,如果还能使次小边也成环,我们的费用又会增加,以此…
http://poj.org/problem?id=3114 题意:有n个城市,m条边,由a城市到b城市的通信时间为w,若a城市与b城市连通,b城市与a城市也连通,则a,b城市之间的通信时间为0,求出从s到t的最少通信时间. 思路:先由Tarjan算法求出图中的连通分量,则在同一个连通分量里的城市之间的通信时间w更新为0,然后利用spfa求出s城市与t城市之间的最短路,即为最少通信时间. #include <stdio.h> #include <string.h> #include…
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…