UVA-1343 The Rotation Game (IDA*)】的更多相关文章

题目 题目     分析 lrj代码.... 还有is_final是保留字,害的我CE了好几发.     代码 #include <cstdio> #include <algorithm> using namespace std; int line[8][7]={ { 0, 2, 6,11,15,20,22}, // A { 1, 3, 8,12,17,21,23}, // B {10, 9, 8, 7, 6, 5, 4}, // C {19,18,17,16,15,14,13},…
The Rotation Game Time Limit: 15000MS   Memory Limit: 150000K Total Submissions: 5691   Accepted: 1918 Description The rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The blocks are marked with symbols 1, 2…
IDA*算法,即迭代加深的A*算法.实际上就是迭代加深+DFS+估价函数 题目传送:The Rotation Game AC代码: #include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <queue> #include <stack> #include <bitset> #include…
题目链接 紫书例题. 首先附上我第一次bfs+剪枝TLE的版本: #include<bits/stdc++.h> using namespace std; typedef long long ll; +,inf=0x3f3f3f3f; ]= { {,,,,,,}, {,,,,,,}, {,,,,,,}, {,,,,,,}, {,,,,,,}, {,,,,,,}, {,,,,,,}, {,,,,,,}, }; ,,,,,,,}; void rot(int* c,int x) { const in…
The Rotation Game Time Limit: 15000MS   Memory Limit: 150000K Total Submissions: 6396   Accepted: 2153 Description The rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The blocks are marked with symbols 1, 2…
题目大意:数字1,2,3都有八个,求出最少的旋转次数使得图形中间八个数相同.旋转规则:对于每一长行或每一长列,每次旋转就是将数据向头的位置移动一位,头上的数放置到尾部.若次数相同,则找出字典序最小旋转次序. 题目分析:IDA*,若当前在第cur层,中间八个数中1,2,3的个数分别为a,b,c.则d=8-max(a,b,c)便是达到目标还需要的理想次数,若cur+d>maxd,则剪枝.<入门经典>上提供了一种BFS的思路,分别以1,2,3为目标广搜3次,不过自己的码力还是太弱,并没有用那种…
题目 题目     分析 IDA*大法好,抄了lrj代码.     代码 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxans=14; int n,a[maxans+1]; bool dfs(int d,int maxd) { if(a[d] == n) return true; if(d == maxd) return false;…
uva 1153 顾客是上帝(贪心) 有n个工作,已知每个工作需要的时间q[i]和截止时间d[i](必须在此前完成),最多能完成多少个工作?工作只能串行完成,第一项任务开始的时间不早于时刻0. 这道题算比较难的贪心了.解法是维护一个关于所有选择的时间的大根堆.将所有工作按照截止时间排序(将二维问题转化为一维问题),然后依次考虑每一个工作.如果当前的总时间t,加上当前工作的时间t1,小于等于当前工作的截止时间d1,那么直接把当前工作加入大根堆中.如果t+t1>d1,说明如果做这个工作,就超时了,所…
题意:从起点出发,可向东南西北4个方向走,如果前面没有墙则可走:如果前面只有一堵墙,则可将墙向前推一格,其余情况不可推动,且不能推动游戏区域边界上的墙.问走出迷宫的最少步数,输出任意一个移动序列. 分析: 1.最少步数--IDA*. 2.注意,若此墙可推动,必须改变当前格子,和沿当前格子向前一步的格子的墙的标记. 3.若沿当前格子向前两步的格子存在,则这个格子的墙的标记也要改变.不存在的情况是:把墙推向了边界. 4.因为每个格子的值是是1(如果正方形以西有一个墙),2(北),4(东)和8(南)的…
Description The Leiden University Library has millions of books. When a student wants to borrow a certain book, he usually submits an online loan form. If the book is available, then the next day the student can go and get it at the loan counter. Thi…