POJ 1184 聪明的打字员】的更多相关文章

简直难到没朋友. 双向bfs + 剪枝. 剪枝策略: 对于2--5位置上的数,仅仅有当光标在相应位置时通过swap ,up.down来改变.那么当当前位置没有达到目标状态时,left和right无意义. 好了.仅仅剪掉这里就过掉了... 还有比較炫酷的方法实现枚举720种排列. .. 然后状压什么的... 功力不够全然看不懂. ... #include <algorithm> #include <iostream> #include <cstring> #include…
链接: http://poj.org/problem?id=1184 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88230#problem/B   (密码:0817) 不同的代码风格,这种在搜时有多种选择的,写了函数感觉看着也方便些, 借鉴 搜索的时候可以去除一些无用的状态,可以发现一个点的值(2-5)如果想要改变那么光标必须在该点处,所以当光标在2-5位置时候,必须要要把值变为与目标位置处一样才可以移动. 代码: #includ…
http://poj.org/problem?id=1184 用字符串s存下数字,并把光标位置做一个字符加到s末尾,用map做标记状态是否出现过,然后bfs即可. 不剪枝是过不了的,考虑的两种交换操作都不涉及到2,3,4,5位置,所以这几个位置只能通过up,down来改变. 如果这几个位置是和目标状态是不一样的,那肯定是用up,down操作是最优的,而不会执行left,right操作. 所以这几个位置只有在和目标状态一样时做left,right操作. #include <iostream> #…
题目链接:http://poj.org/problem?id=1184 分析:首先可以发现有6*10^6种状态,比较多,不过搜索的时候可以去除一些无用的状态, 可以发现一个点的值(2-5)如果想要改变那么光标必须在该点处, 所以当光标在2-5位置时候,必须要要把值变为与目标位置处一样才可以移动. 单搜: #include<stdio.h> #include<queue> #include<string.h> #include<algorithm> using…
起初的想法果然就是一个6000000的状态的表示. 但是后面觉得还是太过于幼稚了. 可以看看网上的解释,其实就是先转换位置,然后再改变数字的大小. #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<queue> #include<cmath> using std::swap; using std::queue; ; ; st…
/* Bfs+Hash 跑的有点慢 但是codevs上时间限制10s 也ok */ #include<iostream> #include<cstdio> #include<cstring> #include<queue> #define maxn 10000010 using namespace std; int len; bool f[maxn]; string ls,rs; struct node { int step,place; string s;…
经典的宽搜题目,感觉最好的办法应该是双向广搜. 不过用简单的启发式搜索可以飘过. #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; int a,b; char ans[1111111][7]; int inf[7]={1,1,10,100,1000,10000,100…
poj1010--邮票问题 DFSpoj1011--Sticks dfs + 剪枝poj1020--拼蛋糕poj1054--The Troublesome Frogpoj1062--昂贵的聘礼poj1077--Eightpoj1084--Square Destroyerpoj1085--Triangle War(博弈,極大極小搜索+alpha_beta剪枝)poj1088--滑雪poj1129--Channel Allocation 着色问题 dfspoj1154--letters (dfs)p…
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递推. 构造法.(POJ 3295) 模拟法.(POJ 1068,POJ 2632,POJ 1573,POJ 2993,POJ 2996) 二…
著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递…