Booksort POJ - 3460 (IDA*)】的更多相关文章

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…
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (…
Repeater POJ - 3768 Harmony is indispensible in our daily life and no one can live without it----may be Facer is the only exception. One day it is rumored that repeat painting will create harmony and then hundreds of people started their endless draw…
题意:从起点出发,可向东南西北4个方向走,如果前面没有墙则可走:如果前面只有一堵墙,则可将墙向前推一格,其余情况不可推动,且不能推动游戏区域边界上的墙.问走出迷宫的最少步数,输出任意一个移动序列. 分析: 1.最少步数--IDA*. 2.注意,若此墙可推动,必须改变当前格子,和沿当前格子向前一步的格子的墙的标记. 3.若沿当前格子向前两步的格子存在,则这个格子的墙的标记也要改变.不存在的情况是:把墙推向了边界. 4.因为每个格子的值是是1(如果正方形以西有一个墙),2(北),4(东)和8(南)的…
Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island…
Farmer John's farm consists of a long row of N (1 <= N <= 100,000)fields. Each field contains a certain number of cows, 1 <= ncows <= 2000. FJ wants to build a fence around a contiguous group of these fields in order to maximize the average nu…
题意:有两种砝码m1, m2和一个物体G,m1的个数x1,  m2的个数为x2, 问令x1+x2最小,并且将天平保持平衡 !输出  x1 和 x2 题解:这是欧几里德拓展的一个应用,欧几里德求不定方程ax+by=c: 先介绍一下: 1. ax+by=gcd(a, b)  相当于a,b互素.则同过欧几里德拓展,有整数解x, y 2.对于 ax+by=c  则转化为  两边同时除以c 再乘以 gcd(a/c, b/c)  这样就化成了 1结论! 3.求一个x的最小值为 x=x*c/gcd(a, b)…
在电影<盗梦空间>中,男主角科布和妻子在梦境中生活了50年,从楼宇.商铺.到河流浅滩.一草一木.这两位造梦师用意念建造了属于自己的梦境空间.你或许并不会想到,在不久未来,这看似科幻的情节将走入人们的日常生活.现在,现实中的造梦行动已经開始在互联网时代悄然上演. 互联网X实验室在<互联网进化论>一书中以前提出互联网正向着与人类大脑高度相似的方向进化,它将具备自己的视觉.听觉.触觉.运动神经系统,也会拥有自己的记忆神经系统.中枢神经系统.自主神经系统.能够称之为互联网虚拟大脑. 同一时…
IDA*算法,即迭代加深的A*算法.实际上就是迭代加深+DFS+估价函数 题目传送:The Rotation Game AC代码: #include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <queue> #include <stack> #include <bitset> #include…
POJ3460 Booksort 题意:给定一个长度为n的序列,每次可以取出其中的一段数,插入任意一个位置,问最少需要几次操作才能使整个序列变为1~n 思路:IDA*+迭代加深搜索 小技巧:将一段数插入到另一段,等价于交换相邻的两端 估价函数:每次操作最多改变三个数的后继,统计错误后继的个数再/3即为最少需要的步数 代码: #include <cstdio> #include <iostream> #include <algorithm> #include <cc…