ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:42.92KB ,
资源ID:3314724      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3314724.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(深度优先搜索.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

深度优先搜索.docx

1、深度优先搜索2488A Knights JourneyTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 20354Accepted: 6857DescriptionBackground The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two s

2、quares in one direction and one square perpendicular to this. The world of a knight is the chessboard he is living on. Our knight lives on a chessboard that has a smaller area than a regular 8 * 8 board, but it is still rectangular. Can you help this adventurous knight to make travel plans? Problem

3、Find a path such that the knight visits every square once. The knight can start and end on any square of the board.InputThe input begins with a positive integer n in the first line. The following lines contain n test cases. Each test case consists of a single line with two positive integers p and q,

4、 such that 1 = p * q = 26. This represents a p * q chessboard, where p describes how many different square numbers 1, . . . , p exist, q describes how many different square letters exist. These are the first q letters of the Latin alphabet: A, . . .OutputThe output for every scenario begins with a l

5、ine containing Scenario #i:, where i is the number of the scenario starting at 1. Then print a single line containing the lexicographically first path that visits all squares of the chessboard with knight moves followed by an empty line. The path should be given on a single line by concatenating the

6、 names of the visited squares. Each square name consists of a capital letter followed by a number. If no such path exist, you should output impossible on a single line.Sample Input31 12 34 3Sample OutputScenario #1:A1Scenario #2:impossibleScenario #3:A1B3C1A2B4C2A3B1C3A4B2C4SourceTUD Programming Con

7、test 2005, Darmstadt, Germany3083Language: Children of the Candy CornTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 6545Accepted: 2851DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wieldi

8、ng psychopaths, hippies, and other terrors on their quest to find the exit. One popular maze-walking strategy guarantees that the visitor will eventually find the exit. Simply choose either the right or left wall, and follow it. Of course, theres no guarantee which strategy (left or right) will be b

9、etter, and the path taken is seldom the most efficient. (It also doesnt work on mazes with exits that are not on the edge; those types of mazes are not represented in this problem.) As the proprieter of a cornfield that is about to be converted into a maze, youd like to have a computer program that

10、can determine the left and right-hand paths along with the shortest path so that you can figure out which layout has the best chance of confounding visitors. InputInput to this problem will begin with a line containing a single integer n indicating the number of mazes. Each maze will consist of one

11、line with a width, w, and height, h (3 = w, h = 40), followed by h lines of w characters each that represent the maze layout. Walls are represented by hash marks (#), empty space by periods (.), the start by an S and the exit by an E. Exactly one S and one E will be present in the maze, and they wil

12、l always be located along one of the maze edges and never in a corner. The maze will be fully enclosed by walls (#), with the only openings being the S and E. The S and E will also be separated by at least one wall (#). You may assume that the maze exit is always reachable from the start point. Outp

13、utFor each maze in the input, output on a single line the number of (not necessarily unique) squares that a person would visit (including the S and E) for (in order) the left, right, and shortest paths, separated by a single space each. Movement from one square to another is only allowed in the hori

14、zontal or vertical direction; movement along the diagonals is not allowed.Sample Input28 8#.#.#.#.#.#.#.#.#.#.#.#S#E#9 5#.#.#.#.#S.E#.#.#.#.#Sample Output37 5 517 17 9SourceSouth Central USA 20063009Curling 2.0Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 6807Accepted: 2841DescriptionOn P

15、lanet 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 marked. They use only a single stone. The purpose of the game is to lead the stone from the start to the goa

16、l with the minimum number of moves.Fig. 1 shows an example of a game board. Some squares may be occupied with blocks. There are two special squares namely the start and the goal, which are not occupied with blocks. (These two squares are distinct.) Once the stone begins to move, it will proceed unti

17、l it hits a block. In order to bring the stone to the goal, you may have to stop the stone by hitting it against a block, and throw again.Fig. 1: Example of board (S: start, G: goal)The movement of the stone obeys the following rules: At the beginning, the stone stands still at the start square. The

18、 movements of the stone are restricted to x and y directions. Diagonal moves are prohibited. When the stone stands still, you can make it moving by throwing it. You may throw it to any direction unless it is blocked immediately(Fig. 2(a). Once thrown, the stone keeps moving to the same direction unt

19、il one of the following occurs: o The stone hits a block (Fig. 2(b), (c). The stone stops at the square next to the block it hit. The block disappears. o The stone gets out of the board. The game ends in failure. o The stone reaches the goal square. The stone stops there and the game ends in success

20、. You cannot throw the stone more than 10 times in a game. If the stone does not reach the goal in 10 moves, the game ends in failure.Fig. 2: Stone movementsUnder the rules, we would like to know whether the stone at the start can reach the goal and, if yes, the minimum number of moves required.With

21、 the initial configuration shown in Fig. 1, 4 moves are required to bring the stone from the start to the goal. The route is shown in Fig. 3(a). Notice when the stone reaches the goal, the board configuration has changed as in Fig. 3(b).Fig. 3: The solution for Fig. D-1 and the final board configura

22、tionInputThe input is a sequence of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 100.Each dataset is formatted as follows.the width(=w) and the height(=h) of the board First row of the board . h-th row of the bo

23、ardThe width and the height of the board satisfy: 2 = w = 20, 1 = h = 20.Each line consists of w decimal numbers delimited by a space. The number describes the status of the corresponding square.0 vacant square1 block2 start position3 goal positionThe dataset for Fig. D-1 is as follows:6 6 1 0 0 2 1

24、 0 1 1 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 1 1OutputFor each dataset, print a line having a decimal integer indicating the minimum number of moves along a route from the start to the goal. If there are no such routes, print -1 instead. Each line should not have any character other th

25、an this number.Sample Input2 13 26 61 0 0 2 1 01 1 0 0 0 00 0 0 0 0 30 0 0 0 0 01 0 0 0 0 10 1 1 1 1 16 11 1 2 1 1 36 11 0 2 1 1 312 12 0 1 1 1 1 1 1 1 1 1 313 12 0 1 1 1 1 1 1 1 1 1 1 30 0Sample Output14-1410-1SourceJapan 2006 Domestic1321棋盘问题Time Limit: 1000MSMemory Limit: 10000KTotal Submissions:

26、 15034Accepted: 7428Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n = 8 , k = n 当为-1 -1时表示输入结束。 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域(数据保证不出现多余的空白行或者空白列)。

27、Output对于每一组数据,给出一行输出,输出摆放的方案数目C (数据保证C231)。Sample Input2 1#.#4 4.#.#.#.#.-1 -1Sample Output21Source蔡错pku2251Dungeon MasterTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 11510Accepted: 4465DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is compo

28、sed 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 by solid rock on all sides. Is an escape possible? If yes, how long will it take? InputThe input consists of a

29、number of dungeons. Each dungeon description starts with a line containing three integers L, R and C (all limited to 30 in size). L is the number of levels making up the dungeon. R and C are the number of rows and columns making up the plan of each level. Then there will follow L blocks of R lines e

30、ach containing C characters. Each character describes one cell of the dungeon. A cell full of rock is indicated by a # and empty cells are represented by a . Your starting position is indicated by S and the exit by the letter E. Theres a single blank line after each level. Input is terminated by thr

31、ee zeroes for L, R and C. OutputEach maze generates one line of output. If it is possible to reach the exit, print a line of the form Escaped in x minute(s). where x is replaced by the shortest time it takes to escape. If it is not possible to escape, print the line Trapped! Sample Input3 4 5S.#.#.#.#.#.#

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1