分析:
题目要求算错路径,显然弗洛伊德算法就不可以用了。
用迪杰斯特拉算法记录路径来源,用DFS来查找路径并存入vector容器。
代码:
#include <bits/stdc++.h>
using namespace std;
int n, m, st, en, city[510], road[510][510], fast[510], ans1, ans2;
bool visit[510];
vector <int> sour[510];//每一个城市的最近路线来源
vector <int> ans3;
vector <int> temp;//在DFS中的暂时最佳路径
void init()//对数据进行初始化
{
for (int i = 0; i<510; i++){
for (int j = 0; j<510; j