真的看不出哪错了,求帮

P1746 离开中山路

用dist数组
by zhangzirui66 @ 2024-03-17 13:47:16


```cpp int bfs(int sx, int sy){ q.push((node){sx, sy}); vis[sx][sy] = 1; while(!q.empty()){ x = q.front().x; y = q.front().y; q.pop(); if(x == ta && y == tb) return dis[x][y]; for(int i = 0; i < 4; i ++){ tx = x + dx[i]; ty = y + dy[i]; if(tx <= 0 || tx > n || ty <= 0 || ty > n) continue; if(mp[tx][ty] == '1' || vis[tx][ty] == 1) continue; dis[tx][ty] = dis[x][y] + 1; vis[tx][ty] = 1; q.push((node){tx, ty}); } } return -1; } ```
by zhangzirui66 @ 2024-03-17 13:48:12


~~给个关注呗~~
by zhangzirui66 @ 2024-03-17 13:48:54


@[Tiks_code](/user/1308662) 数组开小了吧
by ImposterAnYu @ 2024-03-17 14:04:51


@[Tiks_code](/user/1308662) 你对得起银狼头像吗?
by Voltaris @ 2024-03-17 14:23:43


@[Yaofangyu](/user/1007886) 激励自己的嘛
by Tiks_code @ 2024-03-18 10:54:10


@[zhangzirui66](/user/1137373) 感谢感谢
by Tiks_code @ 2024-03-18 10:55:34


|