最短路径问题,参考下网上代码
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
struct Path
{
int i, j;
int dist;
Path(int x, int y, int z){
i = x; j = y; dist = z;
}
friend bool operator<(const Path &a, const Path b) //优先队列默认从大到小排序,所以这里反过来
{return a.dist > b.dist;}
};
int road[101][101];
bool vis[101][101];
int b1,b2,e1,e2,i,j;
int dir[4][2] = {-1,0,1,0,0,1,0,-1};
int main(int argc, char const *argv[])
{
......
阅读全文