Robot
Time limit1sMemory limit512 MB
Find a sequence of at most 700 moves that drives a robot on a walled grid to (0,0) from either of two unknown starting cells.
- Level
Medium6 of 10
- Topics
- BFS, Graph, Simulation, Implementation
- Solved
- No attempts yet
Problem
A robot is placed on a field modeled as an grid. Some of the grid cells are walls.
The robot accepts four types of instructions: up, down, left, right.
Suppose the robot is currently at the coordinate . Then the effect of executing each instruction is as follows.
up: If or is a wall, the robot does not move. Otherwise, the robot moves to .down: If or is a wall, the robot does not move. Otherwise, the robot moves to .left: If or is a wall, the robot does not move. Otherwise, the robot moves to .right: If or is a wall, the robot does not move. Otherwise, the robot moves to .
You know that the starting position of the robot is either or . Find a sequence of at most instructions such that the robot always ends up at whether it starts from or from . It can be proven that a solution exists for every input satisfying the problem constraints.
Constraints
- There exists a finite sequence of instructions to move the robot from to
- There exists a finite sequence of instructions to move the robot from to