随笔分类 -  dfs

LETTERS
摘要:DescriptionA single-player game is played on a rectangular board divided in R rows and C columns. There is a single uppercase letter (A-Z) written in every position in the board. Before the begging of the game there is a figure in the upper-left corner of the board (first row, first column). In ever 阅读全文

posted @ 2013-09-26 11:19 forevermemory 阅读(342) 评论(0) 推荐(0)

Fire Net
摘要:Fire NetTime Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 3Accepted Submission(s) : 1Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board 阅读全文

posted @ 2013-08-17 19:09 forevermemory 阅读(231) 评论(0) 推荐(0)

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 realized that the bone was a trap, and he tried desperately to get out of this maze.The maze was a recta 阅读全文

posted @ 2013-08-12 11:11 forevermemory 阅读(178) 评论(0) 推荐(0)

Beat
摘要:Problem DescriptionZty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solvea problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their rel 阅读全文

posted @ 2013-08-12 08:57 forevermemory 阅读(319) 评论(1) 推荐(0)

哈密顿绕行世界问题
摘要:Problem Description一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。Input前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m=1.m=0退出.Output输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然后个一个: 后列出经过的城市.参看Sample outputSample Input2 5 201 3 122 4 103 5 81 4 65 7 196 8 174 7 98 10 16 阅读全文

posted @ 2013-08-11 22:04 forevermemory 阅读(289) 评论(0) 推荐(0)

下沙小面的(2)
摘要:Problem Description前文再续,书接上一题。话说当上小面的司机的Lele在施行他的那一套拉客法则以后,由于走的路线太长,油费又贵,不久便亏本了。(真可怜~)于是他又想了一个拉客的办法。对于每一次拉客活动,他一次性把乘客都拉上车(当然也不会超过7个,因为位置只有7个)。然后,Lele计算出一条路线(出于某些目的,Lele只把车上乘客的目的地作为这条路线上的站点),把所有乘客都送到目的地(在这路线上不拉上其他乘客),并且使总路线长度最短。不过Lele每次都要花很多时间来想路线,你能写个程序帮他嘛? Input本题目包含多组测试。最后一组测试后有一个0代表结束。每组测试第一行有一个整 阅读全文

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

Sum It Up
摘要:Problem DescriptionGiven a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t=4, n=6, and the list is [4,3,2,2,1,1], then there are four different sums that equal 4: 4,3+1,2+2, and 2+1+1.(A number can be used within a su 阅读全文

posted @ 2013-08-10 12:00 forevermemory 阅读(220) 评论(0) 推荐(0)

N皇后问题
摘要:Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N#include#includeint n;int cnt;int arr[15];bool is(int s){ int i; for(i=0;i=n) { cnt++; return; } for(i=0;i<n;i++) { arr[k]=i; ... 阅读全文

posted @ 2013-08-07 09:16 forevermemory 阅读(200) 评论(1) 推荐(0)

Prime Ring Problem
摘要:Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1.Inputn (0 #include#includeint n;int arr[20];int vis 阅读全文

posted @ 2013-08-05 16:26 forevermemory 阅读(122) 评论(0) 推荐(0)

Safecracker
摘要:Problem Description=== Op tech briefing, 2002/11/02 06:42 CST ==="The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. Fortunately old Brumbaugh from rese 阅读全文

posted @ 2013-08-05 16:23 forevermemory 阅读(249) 评论(0) 推荐(0)

How many ways
摘要:Problem Description这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m)。游戏的规则描述如下: 1.机器人一开始在棋盘的起始点并有起始点所标有的能量。 2.机器人只能向右或者向下走,并且每走一步消耗一单位能量。 3.机器人不能在原地停留。 4.当机器人选择了一条可行路径后,当他走到这条路径的终点时,他将只有终点所标记的能量。如上图,机器人一开始在(1,1)点,并拥有4单位能量,蓝色方块表示他所能到达的点,如果他在这次路径选择中选择的终点是(2,4)点,当他到达(2,4)点时将拥有1单位的能量,并开始下一次路径选择,直到到达(6,6)点。 阅读全文

posted @ 2013-04-18 23:58 forevermemory 阅读(200) 评论(0) 推荐(0)

Substrings
摘要:Problem DescriptionYou are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.InputThe first line of the input file contains a single integer t (1 <= t <= 10), 阅读全文

posted @ 2012-12-13 23:01 forevermemory 阅读(184) 评论(0) 推荐(0)

SUBSTRING
摘要:Problem DescriptionYou are given a string input. You are to find the longest substring of input such that the reversal of the substring is also a substring of input. In case of a tie, return the string that occurs earliest in input.Note well: The substring and its reversal may overlap partially or c 阅读全文

posted @ 2012-12-13 22:43 forevermemory 阅读(169) 评论(0) 推荐(0)

深度优先搜索篇Tempter of the Bone
摘要:Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40933Accepted Submission(s): 11070Problem 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, 阅读全文

posted @ 2012-10-28 20:53 forevermemory 阅读(206) 评论(0) 推荐(0)