随笔分类 -  广搜BFS

摘要: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 which can be represented as an 'X'. Tiles 阅读全文
posted @ 2013-12-01 14:44 persistent codeants 阅读(229) 评论(0) 推荐(0)
摘要:Problem DescriptionLet's play a card game called Gap.You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card.First, you shu2e the cards and lay them face up on the table i 阅读全文
posted @ 2013-11-16 14:07 persistent codeants 阅读(344) 评论(0) 推荐(0)
摘要:Problem DescriptionThe Czech Technical University is rather old — you already know that it celebrates 300 years of its existence in 2007. Some of the university buildings are old as well. And the navigation in old buildings can sometimes be a little bit tricky, because of strange long corridors that 阅读全文
posted @ 2013-11-15 17:58 persistent codeants 阅读(265) 评论(0) 推荐(0)
摘要:Problem DescriptionIgnatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息:密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int n,c,m,i,j,cas; 9 struct node 10 { 11 int left,step; 12 string str... 阅读全文
posted @ 2013-11-14 15:10 persistent codeants 阅读(328) 评论(0) 推荐(0)
摘要:Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子被推到一面墙上,那么箱子只能沿着墙移动.现在给定房间的结构,箱子的位置,搬运工的位置和箱子要被推去的位置,请你计算出搬运工至少要推动箱子多少格.Input输入数据的第一行是一个整数T(1 2 #include 3 #include 4 #include 5 #include 6 7 using namesp... 阅读全文
posted @ 2013-11-14 13:23 persistent codeants 阅读(492) 评论(0) 推荐(0)
摘要:Problem Description在魔方风靡全球之后不久,Rubik先生发明了它的简化版——魔板。魔板由8个同样大小的方块组成,每个方块颜色均不相同,可用数字1-8分别表示。任一时刻魔板的状态可用方块的颜色序列表示:从魔板的左上角开始,按顺时针方向依次写下各方块的颜色代号,所得到的数字序列即可表示此时魔板的状态。例如,序列(1,2,3,4,5,6,7,8)表示魔板状态为:1 2 3 48 7 6 5对于魔板,可施加三种不同的操作,具体操作方法如下:A: 上下两行互换,如上图可变换为状态87654321B: 每行同时循环右移一格,如上图可变换为41236785C: 中间4个方块顺时针旋转一格 阅读全文
posted @ 2013-11-13 11:25 persistent codeants 阅读(738) 评论(0) 推荐(0)
摘要: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 such things every now and then, to keep the enemy in the dark.— Bu 阅读全文
posted @ 2013-10-15 17:24 persistent codeants 阅读(209) 评论(0) 推荐(0)
摘要:Problem DescriptionYou 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 cannot move diagonally and the maze is surrounded b 阅读全文
posted @ 2013-10-14 21:42 persistent codeants 阅读(233) 评论(0) 推荐(0)
摘要:Problem DescriptionThe 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 quest to find the exit.One popular maze-walking strategy guarantees that the visitor 阅读全文
posted @ 2013-10-14 19:58 persistent codeants 阅读(204) 评论(0) 推荐(0)
摘要:Problem DescriptionYou are given two pots, having the volume ofAandBliters respectively. The following operations can be performed:FILL(i) fill the poti(1 ≤i≤ 2) from the tap;DROP(i) empty the potito the drain;POUR(i,j) pour from potito potj; after this operation either the potjis full (and there ma 阅读全文
posted @ 2013-10-12 12:46 persistent codeants 阅读(253) 评论(0) 推荐(0)
摘要:Problem DescriptionGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.InputThe input f 阅读全文
posted @ 2013-10-11 21:52 persistent codeants 阅读(629) 评论(0) 推荐(0)
摘要:1077. Travelling ToursTime limit: 1.0 second Memory limit: 64 MBThere areNcities numbered from 1 toN(1≤N≤200) andMtwo-way roads connect them. There are at most one road between two cities. In summer holiday, members of DSAP Group want to make some traveling tours. Each tour is a route passesKdiffere 阅读全文
posted @ 2013-08-26 20:55 persistent codeants 阅读(307) 评论(0) 推荐(0)
摘要:DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover patch i 阅读全文
posted @ 2013-08-23 09:34 persistent codeants 阅读(205) 评论(0) 推荐(0)
摘要:1495. One-two, One-two 2Time limit: 2.0 second Memory limit: 64 MBA year ago the famous gangster Vito Maretti woke up in the morning and realized that he was bored of robbing banks of round sums. And for the last year he has been taking from banks sums that have only digits 1 and 2 in their decimal 阅读全文
posted @ 2013-08-15 19:34 persistent codeants 阅读(432) 评论(0) 推荐(0)
摘要:1080. Map ColoringTime limit: 1.0 second Memory limit: 64 MBWe consider a geographical map withNcountries numbered from 1 toN(0 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 using namespace std;12 int pay[105];13 queueQ;14 int map[105][105];15 i 阅读全文
posted @ 2013-08-07 18:08 persistent codeants 阅读(397) 评论(0) 推荐(0)
摘要:1033. LabyrinthTime limit: 1.0 second Memory limit: 64 MBAdministration of the labyrinth has decided to start a new season with new wallpapers. For this purpose they need a program to calculate the square of the walls inside the labyrinth. This job is just for you!The labyrinth is represented by a m 阅读全文
posted @ 2013-08-07 13:24 persistent codeants 阅读(294) 评论(0) 推荐(0)