printРабочее место участника

printЗадачи

1158. Blind Walk

Ограничения: время – 2s/4s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

This is a revised description of interactive problem.
Your task is to write a procedure that controls a robot which blindly walks through a maze. The maze is `n\ times\ 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.
7280.png
The picture shows sample maze where blocked cells are, filled and initial robot's location is designated with a circle.
Interaction (revised)
Your procedure should have this interface:
procedure robot; in Pascal or
void robot(); in C/C++.
You should call the function move to control the robot.
function move(s:string):string; in Pascal or
const char *move(const char *s); in C/C++.
This function must be called with one of the following five strings: SOUTH, WEST, NORTH, EAST, or DONE. DONE must be passed when the robot has visited all empty cells. Other strings are selected robot's actions.
The function move returns 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.

Sample transfered data

NORTH
EAST
SOUTH
EAST
SOUTH
WEST
SOUTH
WEST
NORTH
WEST
WEST
NORTH
EAST
NORTH
DONE

Sample returned data

BLOCKED
BLOCKED
EMPTY
BLOCKED
BLOCKED
EMPTY
BLOCKED
BLOCKED
EMPTY
EMPTY
BLOCKED
BLOCKED
EMPTY
BLOCKED
You should submit the source file, that contains the function robot, additional functions and variables.
Source: ACM ICPC NEERC, 2008 (revised)
loading