2713. Blind Walk

单点时限: 5.0 sec

内存限制: 256 MB

This is an interactive problem.

Your task is to write a program that controls a robot which blindly walks through a maze. The maze is n*m (1 <= n,m <= 30) rectangular grid that consists of square cells. Each cell is either empty or blocked.All cells on the border of the maze are blocked. The robot starts in an empty cell. It can move south, west, north, or east to an adjacent empty cell. The robot is blind and has only bump sensors, so when it attempts to move it can either succeed or bump into blocked cell and fail.

The robot has to visit all empty cells in the maze. All cells are guaranteed to be reachable.

Interaction protocol

The program must write to the standard output one line with robot’s action and wait for a line in the standard input with a response, then write next action and read next response, and so on until all empty cells in the maze had been visited. The program must exit only when all cells have been visited. Empty cells may be visited multiple times. It is acceptable to move even after all cells had been visited.

输入格式

Each line of the standard input represents response on robot’s action. It is either a string EMPTY if robot has successfully moved in the specified direction to an adjacent cell or a string BLOCKED if robot’s movement has failed because the corresponding adjacent cell was blocked.

输出格式

Each line of the standard output represents robot’s action. It is one of the following five strings: SOUTH, WEST, NORTH, EAST, or DONE. DONE must be printed when the robot has visited all empty cells. After printing DONE your program must exit. You must flush standard output after printing each action.

样例

Input
BLOCKED
BLOCKED
EMPTY
BLOCKED
BLOCKED
EMPTY
BLOCKED
BLOCKED
EMPTY
EMPTY
BLOCKED
BLOCKED
EMPTY
BLOCKED
Output
NORTH
EAST
SOUTH
EAST
SOUTH
WEST
SOUTH
WEST
NORTH
WEST
WEST
NORTH
EAST
NORTH
DONE

0 人解决,7 人已尝试。

0 份提交通过,共有 29 份提交。

9.9 EMB 奖励。

创建: 16 年前.

修改: 7 年,2 月前.

最后提交: 4 年,10 月前.

来源: NEERC 2008

题目标签