hdu 1026 優先佇列 路徑儲存

2021-05-22 20:01:06 字數 701 閱讀 3314

#include

#include

#include

using namespace std;

#define maxsize 105

char map[maxsize][maxsize];

bool hash[maxsize][maxsize];

int n,m;

struct node

;bool operator <(node a,node b)

node n,p,p[10010],path[10010];

priority_queueq;

int dir[4][2]=,,,};

bool arrive;

int k;

void bfs ()

for (int i = 0; i < 4; i++)

else p.cost = 0;

p.fro = k;

q.push (p);

hash[p.x][p.y] = false;}}

k++;}}

void show()

if(arrive)

}if (n * m -count < (n+m-2))

arrive = false;

bfs();

show();

cout<<"finish"<}return 0;

}

HDU1026 BFS 優先佇列 路徑儲存

剛開始做bfs專題時遇到它,因為路徑儲存放棄了 現在做,剛開始各種wa。後來加了個優先佇列,就ac了。額。include include include include include include include include include include includeusing name...

1026優先佇列

include include using namespace std int n,m,a 2 4 struct node struct labyrinth maze 100 100 int bfs else maze n 1 m 1 c x q.push now while q.empty maz...

HDU 1026 (BFS 記錄路徑)

bfs 路徑記錄 problem id hdu 1026 author id fuqiang11 time 2013 07 17 algorithm bfs status accept include include include using namespace std define inf 0x...