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