/*
给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,
要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。
Input
输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,
且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。
(1<n<=1000, 0<m<100000, s != t)
Output
输出 一行有两个数, 最短距离及其花费。
Sample Input
3 2
1 2 5 6
2 3 4 5
1 3
0 0
Sample Output
9 11
*/
/*
出现的bug
1:输入考虑重边,这tm还不够,重点是输入重边权值相同的时候才需要考虑时间花费
2.先求最短路,当求最短路出现相等松弛时,再考虑时间是否更新的问题
*/
/*迪杰斯特拉算法用于解决单源最短路问题,时间复杂度为o(n^2),权值为正*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define N 1005
#define INF 0x3f3f3f3f
using namespace std;
int start, endd;
int m, n;
int map[N][N],time[N][N];
int dis[N],tim[N];
int vis[N];
int minpath, mintime;
void init()
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <=
hdu3790双权值最短路问题
最新推荐文章于 2021-10-14 17:34:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)