
这一题需要使用搜索,由于这题数据给的比较小,甚至不用剪枝也能够AC,因为题意也比较直接,所以我们直接来看代码。
#include<iostream>
#include<cstdio>
using namespace std;
const int map_std[6][6] = {
{0,0,0,0,0,0},
{0,2,2,2,2,2},
{0,1,2,2,2,2},
{0,1,1,0,2,2},
{0,1,1,1,1,2},
{0,1,1,1,1,1}};//标准图
const int dx[]={-2,-1, 1, 2, 2, 1,-1,-2}; //八个方向
const int dy[]={ 1, 2, 2, 1,-1,-2,-2,-1};
const int maxn = 5 + 5, inf = INT_MAX / 2;
int T, ans, exstep, sx, sy;
int map_try[maxn][m

博客探讨了如何解决校内在线判题系统OJ中编号为P1187的问题,该问题主要涉及搜索算法的应用。尽管数据规模较小,但博主通过直接展示代码来解释解题思路,无需额外的剪枝优化也能获得正确答案。
最低0.47元/天 解锁文章
748

被折叠的 条评论
为什么被折叠?



