(简单)搜索 HOJ 1030 Labyrinth
来源:互联网 发布:网络购票岫岩到沈阳 编辑:程序博客网 时间:2024/06/05 03:00
Labyrinth
Submitted : 816, Accepted : 344
The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them either filled by rock, or free. There is also a little hook on the floor in the center of every free block. The ACM have found that two of the hooks must be connected by a rope that runs through the hooks in every block on the path between the connected ones. When the rope is fastened, a secret door opens. The problem is that we do not know which hooks to connect. That means also that the neccessary length of the rope is unknown. Your task is to determine the maximum length of the rope we could need for a given labyrinth.
Input SpecificationThe input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing two integers C and R (3 <= C,R <= 1000) indicating the number of columns and rows. Then exactly R lines follow, each containing C characters. These characters specify the labyrinth. Each of them is either a hash mark (#
) or a period (.
). Hash marks represent rocks, periods are free blocks. It is possible to walk between neighbouring blocks only, where neighbouring blocks are blocks sharing a common side. We cannot walk diagonally and we cannot step out of the labyrinth.
The labyrinth is designed in such a way that there is exactly one path between any two free blocks. Consequently, if we find the proper hooks to connect, it is easy to find the right path connecting them.
Output SpecificationYour program must print exactly one line of output for each test case. The line must contain the sentence "Maximum rope length isX.
where Xis the length of the longest path between any two free blocks, measured in blocks.
23 3####.####7 6########.#.####.#.####.#.#.##.....########Sample Output:
Maximum rope length is 0.Maximum rope length is 8.
- (简单)搜索 HOJ 1030 Labyrinth
- Hoj 1030 Labyrinth
- 【hoj】1030 Labyrinth
- Labyrinth(深度搜索)
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- HOJ 1030 Labyrinth----------------两次BFS求树的直径(图的最长路)
- (简单) 搜索 HOJ 1066 Substrings
- (简单) 搜索 HOJ 1097 Robot
- (简单)搜索 HOJ 1692 Choose Your Own Adventure
- hdu 4158 hoj 2581 Go 简单搜索
- poj1111 hoj 1639 Image Perimeters 简单搜索
- Go hdu 4158 hoj 简单搜索
- (简单) 搜索 HOJ 1085 Finding Rectangles
- (简单) 搜索 HOJ 1105 Egyptian Multiplication
- (概念题)线段树 HOJ 1119 Atlantis
- (概念题)线段树 HOJ 1495 Area of Simple Polygons
- (概念题)线段树 HOJ 1860 Mars Maps
- (简单)线段树 HOJ 2965 Magic-Pen4
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单)搜索 HOJ 1030 Labyrinth
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- textview 使用自己的字体
- (中等) 搜索 HOJ 1049 sticks
- (简单) 搜索 HOJ 1066 Substrings
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- (简单) 搜索 HOJ 1085 Finding Rectangles
程序博客网,程序员的互联网技术博客家园。csdn论坛精品 msdn技术资料都在这里