经典迷宫问题: P6207 [USACO06OCT] Cows on Skates G 1.广搜可用于查找最少需要的步数,而深搜可求出到达终点的路经数。 2.可开一个数组记录路径,最后用深搜回溯路径。注意起点和终点的设置,可能需要自行补上。
#include
#define int long long
using namespace std;
int r,c,way[155][155][2];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};
char mp[155][155];
bool vis[155][155];
struct node
{
int x,y,s;
};
queueq;
void dfs(int xx,int yy)
{
if(!way[xx][yy][0]&&!way[xx][yy][1]) return;
dfs(way[xx][yy][0],way[xx][yy][1]);
cout
关注
打赏