传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3790
【题目分析】题目的意思是输出两个点之间最短距离和路径,如果最距离有多条,那么就输出话费最少那条。例如,A->B:路径一的距离为5,花费为3,路径二的 距离为5,花费为2。 则输出3 2。所以在存图的时候需要分两种情况存花费。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int M=0x3f3f3f3f;
int map[1000+10][1000+10]; //路径图
int cost[1000+10][1000+10]; //花费图
int dist[1000+10]; //最短路径
int value[1000+10];
int s[1000+10];
int n,m;
void Dijkstra(int ss);
int main()
{
while(scanf("%d%d",&n,&m) && (n || m))
{
int a,b,c,d;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
map[i][j]=M;
cost[i][j]=M;
}
}
for(int i=1;i<=m;i++)
{
scanf("%d%d%d%d"