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

建议使用的浏览器:

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

2841:Navigation Game

题目描述
It's a game played on a specific board about navigation.

Here are the rules:
You can start voyage from any harbor chosen by yourself in the south (the bottom row), and the goal is to reach any harbor in the north (the top row) in shortest time.

Your boat may go north (upward), west (leftward) or east (rightward), just one grid each time, but it cannot navigate to rush to the grid of land or obstacles. In addition, it is considered useless (although sometimes not really) to go backward. So once you leave a grid, you cannot return to it.

It takes only one unit of time to go north, while the time spent on a horizontal (going west/east) movement depends on the number of continuous horizontal movements before this movement. It means that if X continuous horizontal movements have been done just before this movement, the amount of the units of time spent by the next horizontal movement is X + 1.

In the sea, there are some kinds of special objects.
- Obstacles. You cannot move into these grids.
- Fortune's wheels. In this game, Fortune's wheels really look like a weird wheel. You must meet Fortune's wheel ODD TIMES.
- Blessing stones. It costs NO time to go to this kind of grids.
- Invocations of storm. It costs DOUBLE time as normal to go to this kind of grids.
输入解释
There are two integers N and M in the first line. It is guaranteed that both N and M do not exceed 1000. N lines follows, and each line contains M characters describing the grid:

- In first and N-th of there N lines, 'H' stands for harbor, '.' stands for land.
- In other lines, '.', 'O','F','B' and 'S' stand for Empty grids, Obstacles, Fortune's wheels, Blessing stones and Invocations of storm respectively.
输出解释
If a solution exists, output an integer, which is the minimum time required; otherwise, output "No solution".
输入样例
5 11
...H...H...
.O.BF.FS.O.
O.O.OOO.O.O
.O...F...O.
.....H.....
输出样例
6
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 2000MS

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

源链接: POJ-2841

最后修改于 2020-10-29T06:45:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000 131072