为什么我的样例跑出来总是7呢,有大佬能解答下吗
include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N = 110;
int d[N][N],wall[N][N];
int n,m;
typedef pair [HTML_REMOVED] PII;
PII q[N*N];
int bfs(){
q[0] = {0,0};
d[0][0] = 0;
int hh = 0, tt = 0;
int dirx[4] = {-1,0,1,0},diry[4] = {0,1,0,-1};
memset(d,-1,sizeof(d));
while(hh<=tt){
PII t = q[hh];
for(int i = 0; i < 4;i){
int x = t.first + dirx[i], y = t.second + diry[i];
if(x >= 0 && x < n && y >=0 && y < m && d[x][y] == -1 && wall[x][y] != 1){
d[x][y] = d[t.first][t.second] + 1;
q[++tt] = {x,y};
}
}
}
return d[n-1][m-1]+1;
}
int main(){
cin>>n>>m;
for(int i = 0;i [HTML_REMOVED]>wall[i][j];
}
}
cout<<bfs()<<endl;
}