目录
问题:
- 问题:
- 思路
- 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
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?