《算法竞赛进阶指南》0x25广度优先搜索 POJ3322 Bloxorz I

2021-09-21 20:13

阅读:658

标签:坐标   进阶   define   str   als   using   处理   amp   return   题目链接:http://poj.org/problem?id=3322 这题并不难,理解了状态空间的纬度就很容易实现,其中状态是坐标、躺着的起始位置,躺着的形式。 搜索题目比较考验写代码的能力。 代码: #include #include #include #include using namespace std; #define maxn 510 char s[maxn][maxn]; int n,m; bool vis[maxn][maxn][3]; struct node{ int x,y,lie,step; }; node st,ed; int dx[]={0,0,-1,1},dy[]={-1,1,0,0}; //下一跳状态 int next_x[3][4]={{0,0,-2,1},{0,0,-1,1},{0,0,-1,2}}; int next_y[3][4]={{-2,1,0,0},{-1,2,0,0},{-1,1,0,0}}; int next_lie[3][4]={{1,1,2,2},{0,0,1,1},{2,2,0,0}}; int validation(int x,int y){ return x>=1 && x=1 && y


评论


亲,登录后才可以留言!