题目:hdoj 2102 A计划点击打开链接
题意:中文的就不说了。求救出公主所需要的最短时间,所以用广搜。
分析:读题之后不难做,比一般的题目多了一个条件就是可以传送,那么我们可以在广搜里面加一个传送的条件就好了。
其次这个题目注意有个坑就是如果两边都是传送门的话也不行
还有注意广搜写法,如果把队列定义成全局的话注意清空!!
#include <cstdio>
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;
const int N = 20;
int n,m,t;
char mp[3][N][N];
int vis[3][N][N];
int tx[5]={0,0,1,-1};
int ty[5]={1,-1,0,0};
struct Node
{
int x,y,z;
int step;
};
queue<Node> q;
int BFS(Node st,Node en)
{
vis[st.x][st.y][st.z]=1;
q.push(st);
while(!q.empty())