#K60872. RoboVac Perimeter Path Simulation
RoboVac Perimeter Path Simulation
RoboVac Perimeter Path Simulation
You are given a rectangular room whose grid coordinates run from 0 to \(w\) along the x-axis and 0 to \(h\) along the y-axis. A RoboVac starts at the bottom-left corner (0, 0) and moves along the perimeter of the room in a clockwise order with the following rules:
- If there are no obstacles (\(n = 0\)), the RoboVac will travel along the bottom side from (0, 0) to (\(w, 0\)), then the right side from (\(w, 0\)) to (\(w, h\)), then the top side from (\(w, h\)) to (0, h), and finally part of the left side from (0, h) to (0, 1) – stopping before it would revisit the starting point.
- If there is at least one obstacle (\(n > 0\)), obstacles are guaranteed not to lie on the perimeter. In this case the RoboVac will follow the entire perimeter and return to the starting point (0, 0).
Each visited coordinate is output in the format (x, y)
on its own line.
Important: All formulas are rendered in LaTeX format. For example, the room extends for \(w+1\) columns and \(h+1\) rows, where \(w\) and \(h\) are given integers.
inputFormat
The first line contains two integers \(w\) and \(h\) representing the room's width and height.
The second line contains an integer \(n\), the number of obstacles present in the room.
Each of the next \(n\) lines contains two integers denoting the x and y coordinates of an obstacle.
outputFormat
Output the sequence of coordinates the RoboVac visits. Each coordinate should be printed on a separate line in the format (x, y)
.
4 3
0
(0, 0)
(1, 0)
(2, 0)
(3, 0)
(4, 0)
(4, 1)
(4, 2)
(4, 3)
(3, 3)
(2, 3)
(1, 3)
(0, 3)
(0, 2)
(0, 1)
</p>