用vis数组标记到达当前位置的最小时间,如果比最小时间大则不加入队列
#include<stdio.h>
#include<queue>
#include<string.h>
#define inf 0x3fffffff
using namespace std;
char map[30][30];
int n,m,sx,sy,ex,ey;
int cost[4],vis[30][30];
int dir[4][2]={0,1,1,0,0,-1,-1,0};
struct op
{
int x,y,w;
};
int judge(int x,int y)
{
if(x<0||x>=n||y<0||y>=m||map[x][y]=='@')
return 0;
return 1;
}
void bfs()
{
queue<op>Q;
......
阅读全文