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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(Graphs 算法竞赛入门经典 刘汝佳Word文档下载推荐.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Graphs 算法竞赛入门经典 刘汝佳Word文档下载推荐.docx

1、Sample Input1 1*3 5*1 8*5 5*0 0Sample Output12657 - The die is castInterGames is a high-tech startup company that specializes in developing technology that allows users to play games over the Internet. A market analysis has alerted them to the fact that games of chance are pretty popular among their

2、 potential customers. Be it Monopoly, ludo or backgammon, most of these games involve throwing dice at some stage of the game.Of course, it would be unreasonable if players were allowed to throw their dice and then enter the result into the computer, since cheating would be way to easy. So, instead,

3、 InterGames has decided to supply their users with a camera that takes a picture of the thrown dice, analyzes the picture and then transmits the outcome of the throw automatically.For this they desperately need a program that, given an image containing several dice, determines the numbers of dots on

4、 the dice.We make the following assumptions about the input images. The images contain only three dif- ferent pixel values: for the background, the dice and the dots on the dice. We consider two pixelsconnectedif they share an edge - meeting at a corner is not enough. In the figure, pixels A and B a

5、re connected, but B and C are not.A setSof pixels is connected if for every pair (a,b) of pixels inS, there is a sequenceinsuch thata=a1bak, andaiai+1are connected for.We consider all maximally connected sets consisting solely of non-background pixels to be dice. Maximally connected means that you c

6、annot add any other non-background pixels to the set without making it dis-connected. Likewise we consider every maximal connected set of dot pixels to form a dot.The input consists of pictures of several dice throws. Each picture description starts with a line containing two numbers w and h, the wi

7、dth and height of the picture, respectively. These values satisfyThe followinghlines containwcharacters each. The characters can be: . for a background pixel, * for a pixel of a die, and X for a pixel of a dies dot.Dice may have different sizes and not be entirely square due to optical distortion. T

8、he picture will contain at least one die, and the numbers of dots per die is between 1 and 6, inclusive.The input is terminated by a picture starting with= 0, which should not be processed.For each throw of dice, first output its number. Then output the number of dots on the dice in the picture, sor

9、ted in increasing order.Print a blank line after each test case.30 15.*.*.*.*X*.*X*.*.*X*.*X*.*.*.*.*.*.*X*.*X*X*.*.*.*X*.*X*X*.Throw 11 2 2 4784 - Maze ExplorationA maze of rectangular rooms is represented on a two dimensional grid as illustrated in figure 1a. Each point of the grid is represented

10、by a character. The points of room walls are marked by the same character which can be any printable character different than *, _ and space. In figure 1 this character is X. All the other points of the grid are marked by spaces. XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX X X X X X X X#X#X#X X X X

11、X X X X#X X X XXXXXX XXX XXXXXXXXXX XXXXXX#XXX#XXXXXXXXXX X X X X X X X X#X#X#X#X X X * X X X#Xa) Initial maze b) Painted mazeFigure 1. Mazes of rectangular roomsAll rooms of the maze are equal sized with all walls 3 points wide and 1 point thick as illustrated in figure 2. In addition, a wall is sh

12、ared on its full length by the separated rooms. The rooms can communicate through doors, which are positioned in the middle of walls. There are no outdoor doors. door | XX XX X . X measured from within the room door - .- walls are 3 points wide X . X_ XXXXX | |_ walls are one point thickFigure 2. A

13、room with 3 doorsYour problem is to paint all rooms of a maze which can be visited starting from a given room, called the start room which is marked by a star (*) positioned in the middle of the room. A room can be visited from another room if there is a door on the wall which separates the rooms. B

14、y convention, a room is painted if its entire surface, including the doors, is marked by the character # as shown in figure 1b.The program input is a text file structured as follows:1.The first line contains a positive integer which shows the number of mazes to be painted.2.The rest of the file cont

15、ains the mazes.The lines of the input file can be of different length. The text which represents a maze is terminated by a separation line full of underscores (_). There are at most 30 lines and at most 80 characters in a line for each mazeThe program reads the mazes from the input file, paints them

16、 and writes the painted mazes on the standard output.The output text of a painted maze has the same format as that which has been read for that maze, including the separation lines. The example below illustrates a simple input which contains a single maze and the corresponding output.XXXXXXXXXX X XX

17、 * XX XXXXXX_X#X#XX#XX#X705 - Slash MazeBy filling a rectangle with slashes (/) and backslashes (), you can generate nice little mazes. Here is an example:As you can see, paths in the maze cannot branch, so the whole maze only contains cyclic paths and paths entering somewhere and leaving somewhere

18、else. We are only interested in the cycles. In our example, there are two of them.Your task is to write a program that counts the cycles and finds the length of the longest one. The length is defined as the number of small squares the cycle consists of (the ones bordered by gray lines in the picture

19、). In this example, the long cycle has length 16 and the short one length 4.The input contains several maze descriptions. Each description begins with one line containing two integers(), the width and the height of the maze. The nextlines represent the maze itself, and containcharacters each; all th

20、ese characters will be either / or The input is terminated by a test case beginning with= 0. This case should not be processed.For each maze, first output the line Maze #n:, whereis the number of the maze. Then, output the line kCycles; the longest has lengthl.kis the number of cycles in the maze an

21、dlthe length of the longest of the cycles. If the maze does not contain any cycles, output the line There are no cycles.Output a blank line after each test case.6 4/3 3/Maze #1:2 Cycles; the longest has length 16.Maze #2:There are no cycles.439 - Knight MovesA friend of you is doing research on theT

22、raveling Knight Problem (TKP)where you are to find the shortest closed tour of knight moves that visits each square of a given set ofsquares on a chessboard exactly once. He thinks that the most difficult part of the problem is determining the smallest number of knight moves between two given square

23、s and that, once you have accomplished this, finding the tour would be easy.Of course you know that it is vice versa. So you offer him to write a program that solves the difficult part.Your job is to write a program that takes two squaresas input and then determines the number of knight moves on a s

24、hortest route fromtob.Input SpecificationThe input file will contain one or more test cases. Each test case consists of one line containing two squares separated by one space. A square is a string consisting of a letter (a-h) representing the column and a digit (1-8) representing the row on the chessboard.Output SpecificationFor each test case, print one line saying To get fromxxt

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

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