You are given an unknown rectangular room represented as a grid. Each cell is either:
A robot starts from an unknown empty cell, initially facing one of the four cardinal directions (up, right, down, or left). The layout of the room is not available to your program. Instead, you can interact with the robot only through the following operations:
If the robot attempts to move into a blocked cell, it remains in its current position.
Your task is to clean every reachable empty cell exactly once or more using only these operations.
Implement the required algorithm to ensure that all reachable cells are cleaned.
The following operations are available:
bool move(); // Moves forward if possible.
// Returns true if the move succeeds, otherwise false.
void turnLeft(); // Rotates the robot 90° to the left.
void turnRight(); // Rotates the robot 90° to the right.
void clean(); // Cleans the current cell.
void cleanRoom(Robot& robot);
100 × 200clean() on each of them.Expedia • Pending
Expedia • Pending
Teradata • Pending
Teradata • Pending