#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
};
queue<node> q;
int orz[8][2]={{2,-1},{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-2},{1,-2}},n,m,a[500][500],xx,yy;
int main(){
freopen("P1443.txt","r",stdin);
memset(a,-1,sizeof(a));
cin >> n >> m >> xx >> yy;
q.push({xx,yy});
a[xx][yy]=0;
while(!q.empty()){
node w=q.front();
q.pop();
for(int i=0;i<8;i++){
node ww= w;
ww.x+=orz[i][0];
ww.y+=orz[i][1];
if(ww.x<1|| ww.x>n||ww.y<1||ww.y>m) continue;
if(a[ww.x][ww.y]!=-1) continue;
a[ww.x][ww.y]=a[w.x][w.y]+1;
q.push({ww.x,ww.y});
}
}
for(int i=i;i<=n;i++){
for(int j=1;j<=m;j++){
cout << a[i][j] << " ";
}
cout << endl;
}
}
我样例都是对的,下了一份数据也是对的。。。不知道为什么全W、
wflbb