有没有大佬帮忙看看 最后两个点过不去 re是什么错误来着

P1443 马的遍历

你先改一下格式
by mulberror @ 2019-03-03 15:39:49


```cpp #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> using namespace std; int n,m; int a[500][500]; int k[8][2]= {2,1,1,-2,1,2,2,-1,-1,2,-1,-2,-2,1,-2,-1}; void bfs(int x,int y,int s) { int i; if(s>200) return ; a[x][y]=s; for(i=0; i<8; i++) { int dx=x+k[i][0]; int dy=y+k[i][1]; if((dx<=n&&dx>0&&dy<=m&&dy>0&&a[dx][dy]==-1)||a[dx][dy]>(s+1)) bfs(dx,dy,s+1); } } int main() { int i,j,x,y; cin>>n>>m>>x>>y; memset(a,-1,sizeof(a)); bfs(x,y,0); for(i=1; i<=n; i++,cout<<endl) for(j=1; j<=m; j++) printf("%-5d",a[i][j]); return 0; } ```
by 羽生结弦 @ 2019-03-03 15:40:09


@[羽生结弦](/space/show?uid=172199) 为什么不用宽搜
by mulberror @ 2019-03-03 15:47:11


而且方向数组错掉了
by mulberror @ 2019-03-03 15:48:21


出现了两个(-2,1),我是蒟蒻
by mulberror @ 2019-03-03 15:48:54


@[Chhokmah](/space/show?uid=35567) 说实话 不知道什么是宽搜...
by 羽生结弦 @ 2019-03-03 15:48:56


|