搜索
Splaying
Studying
展开
-
HDU1401(Solitaire)
SolitaireProblem DescriptionSolitaire is a game played on a chessboard 8x8. The rows and columns of the chessboard are numbered from 1 to 8, from the top to the bottom and from left to right respectively.There are four identical pieces on the board. In原创 2020-06-05 10:14:59 · 1358 阅读 · 8 评论 -
HDU2102(A计划)
A计划Problem Description可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#表示,墙用*表示,平地用.表示。骑士们一进入时空传输机就会被转到另一层的相对位置,原创 2020-06-02 22:08:02 · 106 阅读 · 0 评论 -
HDU1429(胜利大逃亡(续))
胜利大逃亡(续)Problem DescriptionIgnatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)……这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx,sy)的位置,离开地牢的门在(ex,ey)的位置。Ignatius每分钟只能从一个坐标走到相邻四个坐标中的其中一个。魔王每t分钟回地牢视察一次,若发现Ignatius不在原位置便把他拎回去。经过若干次的尝试,Ignatiu原创 2020-06-02 21:59:06 · 147 阅读 · 0 评论 -
HDU1254(推箱子)
推箱子Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子被推到一面墙上,那么箱子只能沿着墙移动.现在给定房间的结构,箱子的位置,搬运工的位置和箱子要被推去的位置,请你计算出搬运工至少要推动箱子多少格.Input输入数据的第一行是一个整数T(1<=T<=20),原创 2020-06-02 21:50:49 · 407 阅读 · 0 评论 -
HDU3533(Escape)
EscapeProblem DescriptionThe students of the HEU are maneuvering for their military training.The red army and the blue army are at war today. The blue army finds that Little A is the spy of the red army, so Little A has to escape from the headquarters o原创 2020-06-02 21:43:22 · 130 阅读 · 0 评论 -
HDU3567(Eight II)
Eight II题目传送门Problem DescriptionEight-puzzle, which is also called “Nine grids”, comes from an old game.In this game, you are given a 3 by 3 board and 8 tiles. The tiles are numbered from 1 to 8 and each covers a grid. As you see, there is a blank grid原创 2020-05-29 21:01:53 · 176 阅读 · 0 评论 -
HDU1043(Eight)
Eight题目传送门Problem DescriptionThe 15-puzzle has been around for over 100 years; even if you don’t know it by that name, you’ve seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame wit原创 2020-05-29 20:47:02 · 132 阅读 · 0 评论 -
HDU2822(Dogs)
DogsProblem DescriptionPrairie dog comes again! Someday one little prairie dog Tim wants to visit one of his friends on the farmland, but he is as lazy as his friend (who required Tim to come to his place instead of going to Tim’s), So he turn to you for原创 2020-05-29 20:19:22 · 75 阅读 · 0 评论 -
HDU1175(连连看)
连连看Problem Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意见,连线不能从外面绕过去的,但事实上这是错的。现在已经酿成大祸,就只能将错就错了,连线不能从外围绕过。玩家鼠标先后点击两块棋子,试图将他们消去,然后游戏的后台判断这两个方格能不原创 2020-05-29 20:12:32 · 210 阅读 · 0 评论 -
UVA11624(Fire!)
Fire!思路这道题应该是和前面做的杭电那个差不多,先让火跑bfs把到达每一块空地的时间存下来,然后让人去跑bfs看看能不能比火先到这个点,如果能就可以过去,如果人走到这里比火还慢等着被烧死,注意有多个起火点。 UVA的题目一道题判3个小时出结果,刷的比较少。#include <iostream>#include <queue>#include <cstring>#include <cstdio>#include <algorithm&g原创 2020-05-29 18:33:48 · 257 阅读 · 0 评论 -
POJ2251(Dungeon Master)
Dungeon MasterDescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You原创 2020-05-29 18:28:46 · 106 阅读 · 0 评论 -
POJ3414(Pots)
PotsDescriptionYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the pot i to the drain;POUR(i,j) pour from原创 2020-05-29 18:24:15 · 147 阅读 · 0 评论 -
HDU1973(Prime Path)
Prime Path题目传送门Problem DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to change suc原创 2020-05-25 23:04:30 · 97 阅读 · 0 评论 -
HDU2717(Catch That Cow)
Catch That Cow题目传送门Problem DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same原创 2020-05-25 22:58:26 · 143 阅读 · 0 评论 -
HDU1180(诡异的楼梯)
诡异的楼梯题目传送门Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向.比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻找这样的路线,而那个魔法道具上的咒语,正是由你纂写的.Input测试数据有多原创 2020-05-25 22:55:04 · 471 阅读 · 0 评论 -
HDU1195(Open the Lock)
Open the Lock题目传送门Problem DescriptionNow an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9.Each time, you can add or minus 1 to any digit. When add 1 to ‘9’, the digit will原创 2020-05-25 22:46:47 · 189 阅读 · 0 评论 -
HDU2612(Find a way)
find a way题目传送门Problem DescriptionPass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki.Yifenfei’s home is at the countryside, but Merce原创 2020-05-25 22:42:28 · 68 阅读 · 0 评论 -
HDU1495(非常可乐)
非常可乐Problem Description大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>0,N>0,M>0) 。聪明的ACMER你们说他们能平分吗?如原创 2020-05-25 22:38:30 · 119 阅读 · 0 评论 -
HDU1241(Oil Deposits)
Oil DepositsProblem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous s.原创 2020-05-25 22:33:28 · 68 阅读 · 0 评论 -
HDU1728(逃离迷宫)
逃离迷宫Problem Description 给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去。令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中,不能转太多弯了,否则她会晕倒的。我们假定给定的两个位置都是空地,初始时,gloria所面向的方向未定,她原创 2020-05-25 22:31:23 · 189 阅读 · 0 评论 -
HDU1026(Ignatius and the Princess I)
Ignatius and the Princess IProblem 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. To make the problem simply,原创 2020-05-25 22:27:36 · 62 阅读 · 0 评论 -
POJ3984(迷宫问题)
迷宫问题Description定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角的最短路径,格式如样例所示原创 2020-05-25 22:22:03 · 471 阅读 · 2 评论 -
HDU1072(Nightmare)
Nightmare题目传送门Problem DescriptionIgnatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of th原创 2020-05-25 22:18:25 · 157 阅读 · 0 评论 -
HDU1253(胜利大逃亡)
胜利大逃亡Problem DescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个ABC的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图,请你计算出Ignatius能否在魔王回来前离开城堡(只要走到出口就算离开城堡,原创 2020-05-25 22:13:16 · 117 阅读 · 0 评论 -
搜索进阶之迭代加深搜索
迭代加深搜索首先这个不要怕这个东西,其实我刚开始学这个搜索也觉得特别高大上,觉得都是很高大上让人听不懂的专业术语,其实说白了迭代加深搜索的思想和精髓就是控制了搜索深度的dfs,但是却能够达到广搜的效果。它的搜索状态无穷多种,深度可以是无限深,宽度也可以是无限宽。当你采用深搜时会超时,当你采用广搜时队列会螺旋爆炸,这时就需要上迭代加深。比如有这样一类题让你在这类题里面找到最小的解就可以。(通常情...原创 2020-03-16 18:00:38 · 1645 阅读 · 0 评论 -
搜索进阶题
A*搜索A*搜索是启发式搜索的一种,相对于普通bfs搜索加入了优先队列以及一个估计函数h,通过从搜索出发点到当前点的消耗g,以及当前节点到达目标节点的估计值h,通过估计值和当前消耗f = g+h,再借助优先队列小顶堆的优势,每次优先拓展理论上离目标更近的节点。这样搜索出来的结果肯定是最优的而且比是普通广搜快的。难点就是h函数怎么去设计,理论上h函数没有一个严格的设计标准,只要能够加快搜索进度的h...原创 2020-03-13 10:16:26 · 264 阅读 · 0 评论 -
搜索入门之BFS宽度优先搜索
基础搜索入门BFSBFS全称宽度优先搜索算法(又称广度优先搜索)是最简便的图的搜索算法之一,这一算法也是很多重要的图的算法的原型。Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和宽度优先搜索类似的思想。属于一种盲目搜寻法,目的是系统地展开并检查图中的所有节点,以找寻结果。换句话说,它并不考虑结果的可能位置,彻底地搜索整张图,直到找到结果为止。通俗一点的说就像你向一块平静的湖面丢...原创 2020-03-02 21:41:36 · 296 阅读 · 0 评论 -
HDU1242 BFS搜索 + 优先队列
HDU1242(Rescue)题目大意有一个人a被困在迷宫里,然后迷宫里面有很多朋友r救a,注意!注意!注意!这里是多个r,然后’ . ‘代表路,’ # ‘代表墙,’ x ‘代表守卫。经过’ . ‘时需要耗时1,然后经过’ x ‘时需要1,并且需要杀掉守卫,也就是说经过’ x '需要耗时2。然后只能上下左右走,问最短需要多长时间。能够确定的是,这道题是一个搜索题,直接强行BFS搜索就完事了,但...原创 2019-11-15 00:31:52 · 222 阅读 · 0 评论