Under construction

Still being built. Things may change

Child's Game with Robot

Time limit2sMemory limit1024 MB

Summary
The robot starts at the center of a 3x3 grid and must step onto a hidden special square exactly on the tenth action, using moves and echo waits.
Level

Medium4 of 10

Topics
Implementation, Simulation, Brute force
Solved
No attempts yet

Problem

This is an interactive problem.

Little Misha plays a child's game with a robot. The robot stands on a field divided into 3×33 \times 3 squares and surrounded by borders. The game begins at the center square and consists of ten actions. Each action is either a declamation of a phrase or an attempt to move into a neighboring square. Declamation is used to wait, or simply for amusement.

One square is special, but Misha does not know in advance which one. The robot reports when it moves into the special square. The goal is to move into the special square during exactly the tenth action.

To communicate with the robot, Misha uses text input and output. The following commands are recognized:

  • echo phrase: declamation of the phrase.
  • move north: moves one square north.
  • move east: moves one square east.
  • move south: moves one square south.
  • move west: moves one square west.

For each declamation, the robot loudly reads the phrase and prints it back. During a declamation, the robot does not move. The robot correctly handles phrases made of characters with ASCII codes 32 to 126, up to 256 characters long.

For each movement command, the robot prints one of four words:

  • bump: the robot hit a barrier and stays on the same square.
  • moved: the robot moved into a common square.
  • found: the robot moved into the special square during one of the first nine actions.
  • win: the robot moved into the special square during the tenth action.

Help Misha play this game so that the robot prints win during the tenth action.

Hint

The special square is chosen in advance and does not change during the contest.

Examples1

  1. Example 1

    Input
    move north
    move east
    move south
    move west
    move east
    move east
    move south
    echo Ready!
    echo Steady...
    move north
    
    Expected output
    moved
    moved
    found
    moved
    found
    bump
    moved
    Ready!
    Steady...
    win