ACM_最短路
文章平均质量分 76
ACM_sjtsjt
不忘初心 追求美好
展开
-
hdu 3416 spfa+sap
1.spfa计算出最短路2.如果是最短路上的边的话 uv之间建一条容量为1的边 dist[v]=dist[u]+cost[u][v]就能说明uv是最短路上的一条边3.跑一边sap#include#include#include#include#includeusing namespace std;const int MAXN=2222;const int MAXM=333原创 2016-05-14 18:48:31 · 246 阅读 · 0 评论 -
hdu 4571 Travel in time(floyd+dp)
链接http://acm.hdu.edu.cn/showproblem.php?pid=4571距离上的cost用floyd算是否停留用dp求最后遍历dp[i][j]搜索答案#include#include#includeusing namespace std;typedef struct{ int c,s,num;}Point;int g[105][105]原创 2016-03-21 23:35:43 · 353 阅读 · 0 评论 -
hdu 1535 Invitation Cards(邻接表spfa)
Invitation CardsProblem DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater原创 2016-02-17 23:42:14 · 491 阅读 · 0 评论 -
hdoj 1385 Minimum Transport Cost(floyd 记录最短路径)
Minimum Transport CostProblem DescriptionThese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be del原创 2016-02-05 04:57:39 · 243 阅读 · 0 评论 -
hdoj 3790 最短路径问题(根据两个变量的最短路)
多加一个判断就好- -#include #include #include using namespace std;const int N = 1000 + 10;const int MAX = 0xfffffff;int map[N][N], cost[N][N];int min_dist, min_cost;void Dijkstra(int s, int t, int n)原创 2016-02-04 22:51:08 · 369 阅读 · 0 评论 -
hdu 检测赛(最短路中途必须经过两个点)
Problem G没做过这样的题目完全没思路Problem Description给定n个点,m条无向边,1为起点,求从起点出发,至少经过两个点(非起点)并且回到最终回到起点的最短路(中途可以经过起点)点的编号为1到nInput多组用例每个用例的第一行是2个整数n和m(2接下来的m行里,每行包括3个整数a,b,c.代表a和b之间有一条通路,长度为c(0O原创 2016-03-03 10:32:42 · 1918 阅读 · 1 评论 -
hdoj 1217 Arbitrage(floyd+处理名字为字符串的情况)
ArbitrageProblem DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, supp原创 2016-02-02 02:26:28 · 271 阅读 · 0 评论 -
hdoj 2680 最短路(dijkstra)
Choose the best routeProblem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now g原创 2016-02-02 01:05:56 · 317 阅读 · 0 评论 -
【hdu】2433 Travel【最短路删边】
题意:给出一个n节点m条边的图,设这个图所有点之间最短路之和为sum,然后输出删除每一条边之后的sum值,图不联通输出inf题解:第一次计算所有图之间最短路之和的时候在spfa算法里面记录used[i][j][k]代表以i节点为起点进行spfa操作的时候最短路中经过路径j,k然后在之后进行删边操作的时候 注意重边每次都把包含有该条边的也即used[i原创 2016-06-01 22:12:40 · 1457 阅读 · 0 评论