当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3897:Maze Stretching

题目描述
Usually the path in a maze is calculated as the sum of steps taken from the starting point until the ending point, assuming that the distance of one step is exactly 1. Lets assume that we could “stretch” (shorten or extend) the maze in vertical dimension (north-south). By stretching, we are just changing the passed distance between two cells. (it becomes X instead of one). We have a two dimensional maze which has '#' for walls, 'S' in the starting cell and 'E' at the ending cell.
Due to outside conditions, we need to make the shortest path to be exactly L in size. We are not allowed to change the maze configuration, nor to make any changes in the horizontal dimension. We are only allowed to stretch the vertical dimension, and that can be done by any percentage.
Find the percentage of the stretch P, for which the shortest path of the maze will be exactly L.
输入解释
First line of the input contains the number of test cases. For each test case, firstly two numbers L and N are given, where L is the required length of the shortest path and N is the number of lines that are given describing the maze. The following N lines describes the maze such as that each line describes a row of the maze. (Each row length is the horizontal dimension of the maze).
输出解释
For each test case output the percentage of the stretch in the following format:
Case #K: P%
- P should have leading zero if the number is between 0 and 1.
- P should be rounded up on 3 decimals, and always formatted on 3 decimals (with trailing zeros if needed).
输入样例
2
2.5 4
#####
#S  #
#  E#
#####
21 13
############
#S##     #E#
# ##  #  # #
#   # #  # #
### # #  # #
#   # #  # #
#  ## #  # #
##  # #  # #
### # #  # #
##  # #  # #
#  ## #    #
#     #    #
############
输出样例
Case #1: 50.000%
Case #2: 21.053%
提示
Constraints
The height and width of the maze are maximum 100 cells.
All the lines describing one maze are the same size.
There will always be a solution.
The result will be between 0.000 and 1000.000 inclusive
There will be no direct horizontal only path connecting 'S' and 'E'. (the result is always unique).

Explanation of the first test case in the example: On the original maze, the length of the shortest path is 3 because there are two horizontal steps and a vertical one. Our goal is to make the length of the shortest path to be 2.5. That’s why we have to “stretch” the vertical dimension of the maze by a percentage value less than 100. In this case it is 50% which actually changes the vertical distance between two cells to 0.5.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3897

最后修改于 2020-10-29T07:14:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536