各位大佬看看哪错了
#include<bits/stdc++.h>
using namespace std;
struct cc{
int x;
int y;
};
int n , m , sx , sy;
int ans[500][500];
int walk[8][2] = {
{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-2},{1,-2},{2,-1}
};
queue<cc> q;
int main(){
memset(ans , -1 , sizeof(ans));
cin >> n >> m >> sx >> sy;
cc tmp = {sx , sy};
q.push(tmp);
ans[sx][sy] = 0;
while(q.empty()){
cc u = q.front();
int dx = u.x , dy = u.y;
q.pop();
for(int k = 0 ; k < 8 ; k++){
int x = dx + walk[k][0];
int y = dy + walk[k][1];
int d = ans[dx][dy];
if(x < 1 || x > n || y < 1 || y > m || ans[x][y] != -1) continue;
ans[x][y] = d + 1;
cc tmp = {x,y};
q.push(tmp);
}
}
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= m ; j++){
printf("%-5d",ans[i][j]);
}
printf("\n");
}
return 0;
}