用BFS 求最短路(较复杂)

本文介绍如何利用BFS算法寻找图的最短路径,并讨论在路径较长时,如何通过循环和vector避免递归导致的栈溢出问题。
摘要由CSDN通过智能技术生成

题目链接

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<set>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
#define maxn 15
#define inf 0x3f3f3f3f
#define ll long long
#define mod 1000000007
const char * chao ="NESW";
const char * zuan ="LFR";
int dx[4]={
   -1,0,1,0};
int dy[4]={
   0,1,0,-1};
int nd[maxn][maxn];
int has_edge[maxn][maxn][4][3];
int d[maxn][maxn][4];
int n,m,e1,d1,fd;
char dir;
struct node
{
   
    int x,y,di;
};
node p[maxn][maxn][4];
int found(const char * ch
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值