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

建议使用的浏览器:

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

2644:Maze

Special Judge 特殊评判
题目描述
You have been blindfolded and deposited someplace in a maze. You have no idea where you are. You do know, however, that the maze is laid out on a grid, and that each grid location is either blocked or free. In fact, you have memorized a map of the maze. Also, your magnetic personality allows you to always sense which direction is north.
In this maze, you have four possible moves: north, south, east, and west. Your task is to find the shortest sequence of moves that will guarantee your escape, regardless of your initial placement in the maze. You have "escaped" whenever you reach a square on an outside edge of the grid (and if you start there, then you've already escaped). Further moves are irrelevant once you have escaped. If you try to walk into a wall, you will simply stay in the same spot.

You may assume that it is possible to escape from every unblocked position in the maze.
输入解释
Input consists of a positive integer n <= 8, followed by n lines giving the rows of an n by n grid. This grid describes the maze you are trapped in. Written on the screen, north is up. Blocked locations are denoted by the character "O" (that's an uppercase "o"), while unblocked locations are indicated by the character ".".
输出解释
Output consists of a number of lines, each consisting of one of "north", "south", "east", or "west", indicating the shortest sequence of moves that guarantees escape for any possible unblocked starting position.
If there are multiple possible shortest sequences, any of them will do.
输入样例
4
OO.O
...O
OO..
O..O
输出样例
east
north

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

源链接: POJ-2644

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

共提交 0

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