Honeycomb Gym - 102028F

bfs搜索蜂巢

#include 
#include 
#include 
#include 

using namespace std;

#define INF 0x3f3f3f3f

int vis[10005][10005];
char str[10005][10005];
int n,m;
int stx,sty,ex,ey;
struct node{
    int x,y,num;
};
int mx[6] = {1, 1, -1, -1, 2, -2};
int my[6] = {3, -3, 3, -3, 0, 0};
int bfs()
{
    queue que;
    que.push(node {stx,sty,1});
    vis[stx][sty]=0;
    while(!que.empty())
    {
        node t=que.front();que.pop();
        if(t.x==ex&&t.y==ey)
            return t.num; 
        for(int i=0;i<6;i++)
        {
            int xx,yy;
            xx=t.x+mx[i];
            yy=t.y+my[i];
            if(xx>=0&&xx=0&&yy=0&&xxx=0&&yyy

 

你可能感兴趣的:(搜索)