目录
问题:
- 问题:
- 思路
- CODE
- Y总CODE:
输出最小步数
思路同样的 我们可以通过转移
每次转移我们只需要对前面的一次操作加一即可
我的代码有误 不清楚 不习惯用Piar
CODE#include
using namespace std;
const int N = 150;
char g[N][N];
int n,m,st[N][N];
int ex ,ey;
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int dist[N][N];
struct node
{
int x,y,cnt;
};
void bfs(int x,int y)
{
queue q;
st[x][y] = 1;
q.push({x,y,0});
while(!q.empty())
{
node t = q.front();
q.pop();
for(int i =0 ; i0&&fx0&&fy>g[i];
bfs(x,y);
}
int main()
{
solve();
return 0;
}
Y总CODE:
#include
#include
#include
#define x first
#define y second
using namespace std;
typedef pair PII;
const int N = 155, M = N * N;
int n, m;
char g[N][N];
PII q[M];
int dist[N][N];
int bfs()
{
int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
int sx, sy;
for (int i = 0; i n;
for (int i = 0; i > g[i];
cout
关注
打赏