随笔分类 -  bfs

连连看
摘要:Problem Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意见,连线不能从外面绕过去的,但事实上这是错的。现在已经酿成大祸,就只能将错就错了,连线不能从外围绕过。玩家鼠标先后点击两块棋子,试图将他们消去,然后游戏的后台判断这两个方格能不能消去。现在你的任务就是写这个后台程序。Input输入数据有多组。每组数据的第一行有两个正整数n,m 阅读全文

posted @ 2013-08-14 00:11 forevermemory 阅读(506) 评论(0) 推荐(0)

Eight
摘要: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 with one tile missing. Let's call the missing tile ' 阅读全文

posted @ 2013-08-02 16:47 forevermemory 阅读(647) 评论(0) 推荐(0)

Gap
摘要: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 阅读全文

posted @ 2013-07-31 12:11 forevermemory 阅读(280) 评论(0) 推荐(0)

非常可乐
摘要:Problem Description大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>0,N>0,M>0) 。聪明的ACMER你们说他们能平分吗?如果能请输出倒可乐的最少的次数,如果不能输出"NO"。Input三个整数 : S 阅读全文

posted @ 2013-06-16 10:44 forevermemory 阅读(183) 评论(0) 推荐(0)

找宝箱
摘要:Problem Description作为一个强迫症患者,小 Y 在走游戏里的迷宫时一定要把所有的宝箱收集齐才肯罢休。现在给你一个 N *M 的迷宫,里面有障碍、空地和宝箱,小 Y 在某个起始点,每一步小 Y 可以往上下左右走,当然前提时没有走出迷宫并且走到的点不是障碍。如果小 Y 走到了某个为宝箱的点,那么这个宝箱就被他收集到了,然后此处变为空地。 现在你需要计算小 Y 最少需要走多少步才能收集齐所有的宝箱。Input输入包含多组数据。 对于每组数据,第一行两个正整数 N;M(1<=N;M<=100),表示迷宫大小。 接下来 N 行,每行 M 个整数,第 i + 1 行的第 j 阅读全文

posted @ 2013-03-29 09:12 forevermemory 阅读(432) 评论(0) 推荐(0)

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 change to be '1' and when minus 1 to '1' 阅读全文

posted @ 2013-03-28 12:50 forevermemory 阅读(466) 评论(0) 推荐(0)

基因
摘要:Problem Description作为一个基因工程师,Enigma遇到了一个关于基因重组的难题。总所周知,基因可以被看出一个核苷酸序列,这个序列可以简单地用四个字母A,C,G和T表示。Enigma得到了一个基因“ATCC”,他想把它重组为一个新的基因“CTCA”。他可以任意使用下列两种方法:(1) 交换基因的前两个字符; (2) 将第一个字符移到最后。例如:“ATCC”经过方法2重组为“TCCA”,然后“TCCA”经过方法1重组从而得到了“CTCA”。你的任务是写个程序帮助Enigma发现重组基因的最小步骤。 Input输入有多个实例,每个实例的第1行整数N表示基因的长度(1<=N& 阅读全文

posted @ 2013-03-17 21:52 forevermemory 阅读(229) 评论(0) 推荐(0)

诡异的楼梯
摘要:Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻找这样的路线,而那个魔法道具上的咒语,正是由你纂写的. Input测试数据有多组,每组的表述如下:第一行有两个数,M和N,接下来是一个M行N列的地图,'*'表示障碍物,' 阅读全文

posted @ 2013-03-12 15:15 forevermemory 阅读(232) 评论(0) 推荐(0)

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 the bomb is set to 6 minutes. To prevent the bomb from explodin 阅读全文

posted @ 2013-03-09 10:34 forevermemory 阅读(240) 评论(0) 推荐(0)

Rescue
摘要:Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to save Angel. Their task is: approach Angel. We assume that "approach Angel 阅读全文

posted @ 2013-03-09 09:12 forevermemory 阅读(197) 评论(0) 推荐(0)

胜利大逃亡
摘要:Problem DescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图,请你计算出Ignatius能否在魔王回来前离开城堡(只要走到出口就算离开城堡,如果走到出口的时候魔王刚好回来也算逃亡成功),如果可以请输出需要多少分钟才能离开,如果不能则输出-1 阅读全文

posted @ 2013-03-08 10:52 forevermemory 阅读(115) 评论(0) 推荐(0)

Oil Deposits
摘要:Problem 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 square plots. It then analyzes each plot separately, using s 阅读全文

posted @ 2013-03-07 20:38 forevermemory 阅读(174) 评论(0) 推荐(0)

Red and Black
摘要:Problem DescriptionThere 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't move on red tiles, he can move only on black tiles.Write a program to count 阅读全文

posted @ 2013-03-07 19:59 forevermemory 阅读(171) 评论(0) 推荐(0)

Knight Moves
摘要:Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determi 阅读全文

posted @ 2013-03-06 23:26 forevermemory 阅读(206) 评论(0) 推荐(0)

素数切换
摘要:Problem I Time Limit : 3000/1000ms (Java/Other)Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 3Accepted Submission(s) : 3Font: Times New Roman | Verdana | Georgia Font Size: ← →Problem Description最近ZC对素数的一些变换十分感兴趣,于是自定义了一款素数变换游戏。游戏规则如下:1.随机给你a,b两个素数,问由a变换到b的最少步数。2.规定每次只能变素数的一个数位。3.规定每 阅读全文

posted @ 2012-11-25 17:31 forevermemory 阅读(336) 评论(0) 推荐(0)

Rescue
摘要:RescueTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9513Accepted Submission(s): 3477Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, 阅读全文

posted @ 2012-10-30 00:31 forevermemory 阅读(193) 评论(0) 推荐(0)