#C360. Cleanable Cells
Cleanable Cells
Cleanable Cells
You are given a grid with dimensions (n \times m). In this grid, some cells contain obstacles, and the remaining cells are empty. The starting position of a vacuum cleaner is given by ((sx, sy)) (0-indexed). The value (k) indicates the number of obstacles in the grid. From the starting cell, the vacuum cleaner can move in four directions: up, down, left, and right. It can only move to an adjacent cell if that cell is within the grid boundaries and does not contain an obstacle.
Your task is to compute the total number of cells that the vacuum cleaner can reach, including the starting cell. Movement is only allowed to immediately adjacent cells and obstacles block movement.
inputFormat
Input is given via standard input (stdin) and has the following format:
The first line contains five integers (n), (m), (k), (sx), and (sy), where (n) and (m) represent the dimensions of the grid, (k) is the number of obstacles, and ((sx, sy)) is the starting cell (0-indexed).
Each of the next (k) lines contains two integers (ox) and (oy), which represent the coordinates of an obstacle.
outputFormat
Output a single integer to standard output (stdout): the total number of reachable cells from the starting position, including the starting cell.## sample
5 5 2 0 0
1 2
3 3
23
</p>