随笔分类 -  最短路径

摘要:题目链接求让城市1到其他城市在保证最短路的情况下求最小花费,最短路水题。#include #include #include #include using namespace std;const int INF=1e9;struct edge{ int u,v; int len,cost... 阅读全文
posted @ 2015-03-15 00:39 Scale_the_heights 阅读(176) 评论(0) 推荐(0)
摘要:Fire StationTime Limit:5000MSMemory Limit:65536KTotal Submissions:3846Accepted:1362DescriptionA city is served by a number of fire stations. Some resi... 阅读全文
posted @ 2015-01-31 15:42 Scale_the_heights 阅读(138) 评论(0) 推荐(0)
摘要:Invitation CardsTime Limit:8000MSMemory Limit:262144KTotal Submissions:20249Accepted:6618DescriptionIn the age of television, not many people attend t... 阅读全文
posted @ 2015-01-29 22:26 Scale_the_heights 阅读(181) 评论(0) 推荐(0)
摘要:题目大意及思路:一个人从某个城市去另一个城市,在途经的某个城市(包括起点和终点)要请人吃饭,在每个城市吃饭的花费不同,在每个城市间行走所需费用也不同。现在他在旅途中吃饭最贵的城市请人吃饭,问总的花费最小是多少。Sample Input7 8 52 3 5 15 4 4 61 2 201 4 201 ... 阅读全文
posted @ 2015-01-12 19:00 Scale_the_heights 阅读(194) 评论(0) 推荐(0)
摘要:最长路径,和最短路径差不多,用了spfa来求#include #include #include #include #define N 1000using namespace std;int g[N][N];int dis[N];int vis[N];void spfa(int n,int s){ ... 阅读全文
posted @ 2014-11-10 22:49 Scale_the_heights 阅读(158) 评论(0) 推荐(0)
摘要:直接找路径中最小值的最大值,最小的最大这个概念好好理解下就行了#include #include #include #include #define INF 1e10using namespace std;const int N=1000;int dis[N][N];int main(){ i... 阅读全文
posted @ 2014-11-10 22:46 Scale_the_heights 阅读(189) 评论(0) 推荐(0)
摘要:最短路径问题/*解题关键点:1、度数为奇数的顶点(简称为奇顶点)个数必然为偶数。2、题目说明奇顶点数目小于等于2,所以奇顶点必然为0或2,当奇顶点个数为0的时候,肯定是一笔走完(欧拉),当奇顶点个数为2时,就转化为单源最短路径,并且起点和终点就是两个奇顶点*/#include #include #i... 阅读全文
posted @ 2014-11-10 13:41 Scale_the_heights 阅读(165) 评论(0) 推荐(0)