这是什么神仙写法。。
by NaCly_Fish @ 2019-03-30 01:14:44
```cpp
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int n,m;
int x,y;
int plat[450][450];
int book[450][450];
int dx[16]={2,-2,2,-2,-1,1,-1,1};
int dy[16]={1,1,-1,-1,2,2,-2,-2};
struct node{
int x;
int y;
int s;
};
void bfs(){
queue <node> q;
node now;
now.x=x;
now.y=y;
now.s=0;
q.push(now);
plat[x][y]=0;
book[x][y]=1;
while(q.empty()==false){
now=q.front();
q.pop();
for(int i=0;i<8;i++){
int tx=now.x+dx[i];
int ty=now.y+dy[i];
if(tx<1||ty<1||tx>n||ty>m){
continue;
}
if(book[tx][ty]==1){
continue;
}
node next;
next.x=tx;
next.y=ty;
next.s=now.s+1;
plat[tx][ty]=next.s;
q.push(next);
book[tx][ty]=1;
}
}
}
int main(){
cin>>n>>m;
cin>>x>>y;
memset(book,0,sizeof(book));
memset(plat,-1,sizeof(plat));
bfs();
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++) printf("%-5d", plat[i][j]);
cout<<endl;
}
}
```
by Tazo @ 2019-03-30 07:53:04
很标准的sb'写法
by Tazo @ 2019-03-30 07:53:39
@[xgdqrb](/space/show?uid=116634) 你怎么这么秀?!这种题还要用指针!
by HPXXZYY @ 2019-03-30 08:29:34