
└──搜索
文章平均质量分 79
Kuro同学
这个作者很懒,什么都没留下…
展开
-
csu 1106 最优对称路径 最短路+记忆化搜索.
题目链接:csu1106解题思路:首先思考如何得到一条对称的路径:分别从起点和终点出发,并走对称的方向,最后在对角线汇合,所有点权之和即是这条路径的的路程我们很容易发现,模拟 终点到对角线的过程 是多余的,因为它的路径和 起点到对角线所走的路径 是对称的.....我们只需要将整个地图沿对角线对折,重合的点累加,那么我们从起点(已和终原创 2015-08-24 14:25:28 · 1271 阅读 · 0 评论 -
code vs1099 字串变化 字符串搜索(STL)
题目链接:http://codevs.cn/problem/1099/题解思路:1.用string 类型来保存字符串 方便插入比较等操作2.用STL set来判断当前字符串是否出现过注意字符串的下标代码:#include#include#include#include#include#includeus原创 2015-06-25 21:41:02 · 1234 阅读 · 0 评论 -
POJ 3083 Children of the Candy Corn (bfs+dfs)
The cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their que原创 2014-07-07 16:03:05 · 786 阅读 · 0 评论 -
HDU 2102 A计划 双层BFS
Problem Description可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位原创 2014-07-29 09:40:09 · 1075 阅读 · 0 评论 -
poj1129 Channel Allocation 染色问题
DescriptionWhen a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. However, the channels used by each rep原创 2014-08-28 15:17:24 · 1268 阅读 · 0 评论 -
NOIP 灯的排列问题
题目描述设在一排上有N个格子(N≤20),若在格子中放置有不同颜色的灯,每种灯的个数记为N1,N2,……Nk(k表示不同颜色灯的个数)。 放灯时要遵守下列规则: ①同一种颜色的灯不能分开; ②不同颜色的灯之间至少要有一个空位置。 例如:N=8(格子数) R=2(红灯数) B=3(蓝灯数) 放置的方法有:原创 2014-11-21 18:51:27 · 2733 阅读 · 0 评论 -
POJ2935 Basic Wall Maze bfs记录路径
链接: POJ2935题意:6 X 6的地图 格子和格子可能有墙 整个地图中有三道墙 求起点起点到终点的路径本题中的墙可以理解为某a位置的X方向不能走 即用一个三维数组map[x][y][z]表示(x,y)的Z方向不能走关于记录路径可以用一个pre数组记录每个坐标的前一个坐标的复合值 最后倒序输出方向即可原创 2015-01-20 15:09:46 · 1102 阅读 · 0 评论 -
HDU1312 Red and Black 搜索
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can'原创 2014-07-06 19:26:50 · 700 阅读 · 0 评论 -
CSUOJ 1336 Interesting Calculator spfa / 优先队列
DescriptionThere is an interesting calculator. It has 3 rows of buttons. Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of the display.Row 2: button +0,原创 2014-09-06 11:02:07 · 1341 阅读 · 1 评论 -
POJ 1324 Holedox Moving 贪吃蛇 状态压缩 BFS
DescriptionDuring winter, the most hungry and severe time, Holedox sleeps in its lair. When spring comes, Holedox wakes up, moves to the exit of its lair, comes out, and begins its new life.Holedo原创 2015-01-20 09:58:27 · 1256 阅读 · 0 评论 -
hiho1087 Hamiltonian Cycle 位运算+记忆化搜索 求哈密顿回路数量
题目链接:hiho1087题目详解:题目详解代码:#include#include#include#define maxn 20using namespace std;int next_all[maxn]={0};int pos[1<<maxn];int dp[maxn][1<<maxn];int原创 2015-09-19 21:13:08 · 1042 阅读 · 0 评论 -
UVA11882 Biggest Number 强剪枝
题目链接:UVA11882解题思路:常规思路是 枚举每个点,暴力dfs,然后选择最大的那个 但题目只给了1000MS 这就需要剪枝了剪枝1:假设当前答案长度为ans,那么当我们走到一个点(x, y)的时候,bfs一下判断能接触的格子数。假设现在能从(x, y)走到的点,我们都能到达,这是最好的情况。设从(x, y)能走到的点数为maxlen,那么如原创 2015-08-02 16:43:07 · 1500 阅读 · 0 评论 -
HDU5335 Work Out 层次遍历
题目链接:HDu5335题意:1000X1000的地图, 问通过四个方向从(1,1)走到(1000,1000)所经过的最小二进制序列是多少.解题思路:首先应该通过bfs找到 (1,1)能走到的值为0且最接近右下角的位置 (x+y值最大 ,有多个全部保存)这样就能保证接下来找的序列是最短的接下来每一步的原创 2015-07-30 20:55:56 · 956 阅读 · 0 评论 -
POJ 1753 Flip game
DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying e原创 2014-07-17 16:47:15 · 746 阅读 · 0 评论 -
HDU 1254 (经典游戏)推箱子 BFS+dfs
Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子被推到一面墙上,那么箱子只能沿着墙移动.现在给定房间的结构,箱子的位置,搬运工的位置和箱子要被推去的位置,请你原创 2014-08-06 17:09:14 · 2235 阅读 · 0 评论 -
POJ 3414 Pots 记录路径的广搜
题意:有两个空瓶 a,b是它们的容量,c是容量目标, 可以有三种操作 充满任意一瓶,倒空任意一瓶,将任意一瓶倒入另一瓶(能剩下但不能溢出);求任意一瓶的体积达到目标体积所需要的最小操作数,并依此输出该操作。原创 2014-07-24 10:43:29 · 1268 阅读 · 0 评论 -
poj3322 Bloxorz I(滚箱子游戏) 状压BFS
题目链接:POJ3322游戏链接:http://www.4399.com/flash/6860_3.htm题意: 有一个长方体,给出它的起始位置(可能竖着,可能躺着)问它通过滚动最少多少步能到达终点解题思路:BFS 由于每一步可能有竖着和横着两种情况,如果是躺着,不可能记录两个坐标,我们只需要记录靠左上的节点即可,原创 2015-08-02 09:45:54 · 1423 阅读 · 0 评论 -
hiho 小Hi小Ho的惊天大作战:扫雷·一 扫雷·三
题目链接:扫雷1扫雷3扫雷2并不科学(见扫雷3里的第一个提示,)然后就没写了- -思路:扫雷一:只有一行枚举第一个格子为有雷 或者 没有雷然后再往下搜索 得到多个可行解所有可行解的某个位置都为雷的一定为雷所有可行解的某个位置都不为为雷的一定为不为雷扫雷三:思路1:未知的位置只有不超过10个,直接爆力枚举原创 2015-06-12 18:15:46 · 1784 阅读 · 0 评论 -
HDU1180 诡异的楼梯 广搜 优先队列
Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向.比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法原创 2014-07-26 19:59:06 · 1791 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone 深搜剪枝
Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He re原创 2014-08-04 20:18:43 · 820 阅读 · 0 评论 -
NOIP 2002 马拦过河卒 BFS+递推
Description :如图,A点有一个过河卒,需要走到目标B点。卒行走的规则:可以向下、或者向右。同时在棋盘上的任一点有一个对方的马(如上图的C点),该马所在的点和所有跳跃一步可达的点称为方马的控制点。例如上图C点上的马可以控制9个点(图中的P1,P2...P8和C)。卒不能通过对方的控制点。棋盘用坐标表示,A点(0,0)、B点(n, m)(n,m为不超过20的整数,并原创 2014-11-27 13:09:31 · 3138 阅读 · 1 评论 -
POJ 3009 Curling 2.0 深搜求最小路径
On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is mark原创 2014-07-09 08:13:08 · 655 阅读 · 0 评论 -
HDU 1242 rescue and 优先队列入门
Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M Angel's friends want to save Angel. Their task is: approach Angel. W原创 2014-07-23 15:39:54 · 1033 阅读 · 0 评论 -
HDU 5025 Saving Tang Monk 记忆化BFS+状态压缩
Problem Description《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en during the Ming Dynasty. In this novel, Monkey原创 2014-10-06 20:51:04 · 1154 阅读 · 0 评论 -
hdu1455 Sticks 深搜 强剪枝
题意:给多组数据,每组数据代表一些小木棍,能否将它们全部用完组成(尽量)多个相同长度的长棍,并输出长棍的长度原创 2014-07-26 14:54:11 · 1430 阅读 · 0 评论 -
POJ 1915 Knight Moves 双向BFS 入门
DescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is原创 2014-07-30 20:50:42 · 1189 阅读 · 0 评论 -
POJ 1579 Function Run Fun 记忆化搜索
DescriptionWe all love recursion! Don't we?Consider a three-parameter recursive function w(a, b, c):if a 1if a > 20 or b > 20 or c > 20, then w(a, b, c) returns:w(20, 20, 20)if a原创 2014-08-27 15:06:31 · 1020 阅读 · 0 评论 -
zoj 3103 Cliff Climbing 优先队列+BFS
题目链接:3103题意:一块N X M 的墙壁,求从S点出发 到T点的最短时间 每次只能爬一步,且只能左右脚交替爬行,墙上每个方块中的数字标明方块的"光滑等级",标有数字t 的方块将花费他t 个单位时间安全地将他的脚踏在上面。题解:队列结构体中有4个变量(x,y,步数,固定的脚(0左脚,1右脚))。将所有s点原创 2015-02-04 21:23:35 · 1062 阅读 · 0 评论 -
HDU1426 数独游戏 搜索
Problem Description自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。所以全球人民前仆后继,为了奖品日夜训练茶饭不思。当然也包括初学者li原创 2014-09-12 18:53:16 · 1038 阅读 · 0 评论 -
POJ 搜索题集
poj1010——邮票问题 DFSpoj1011——Sticks dfs + 剪枝poj1020——拼蛋糕poj1054——The Troublesome Frogpoj1062——昂贵的聘礼poj1077——Eightpoj1084——Square Destroyerpoj1085——Triangle War(博弈,極大極小搜索+alpha_beta剪枝)po原创 2014-07-29 15:12:47 · 1319 阅读 · 0 评论 -
hdu1198 Farm Irrigation dfs
Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has原创 2015-01-15 16:57:14 · 1028 阅读 · 0 评论 -
POJ1321 棋盘问题 回溯法
#includeusing namespace std;int s,m,n;int vis[10][10];char map[10][10];bool shu[9];void dfs(int x,int y){ if(y==n) { s++; return; } if(x>m) return; for(int j=1;j<=m;j++) { if(vis原创 2014-07-06 11:22:33 · 866 阅读 · 0 评论 -
poj1020 Anniversary Cake 搜索
DescriptionNahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited pe原创 2015-01-15 08:58:03 · 1068 阅读 · 0 评论 -
POJ 2965 The Pilots Brothers' refrigerator 搜索+枚举
DescriptionThe game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.There are 16 handles on the refrigerator door. Every handle can b原创 2014-07-17 20:45:56 · 800 阅读 · 0 评论 -
HDU 1518 Square 搜索
Problem DescriptionGiven a set of sticks of various lengths, is it possible to join them end-to-end to form a square? InputThe first line of input contains N, the number of test cases. Eac原创 2014-07-25 17:47:15 · 993 阅读 · 0 评论 -
HDU 1026 Ignatius and the Princess I 记录 路径广搜
Problem DescriptionThe Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth.原创 2014-08-07 20:47:57 · 894 阅读 · 0 评论 -
HDU 5024 (广州网络赛) Wang Xifeng's Little Plot 记忆化搜索+枚举
Problem Description《Dream of the Red Chamber》(also 《The Story of the Stone》) is one of the Four Great Classical Novels of Chinese literature, and it is commonly regarded as the best one. This novel原创 2014-09-22 14:23:12 · 996 阅读 · 0 评论 -
hiho1233 Boxes 记忆化搜索
题目链接:hiho1233题意:有一个类似汉诺塔的游戏,共有n个柱子和n个大小不同的盘子每个盘子可以移动到相邻的柱子上去,同时盘子可以叠加,但要求小的盘子放在大的盘子上面问从当前状态到目标状态(n个盘子从小到大依次排列在n个柱子上)所需要移动的最小次数解题思路:首先要离散化(1~n)最小步数------bfs原创 2015-09-23 15:46:04 · 767 阅读 · 0 评论