#K46207. Minimum Tiles to Cover Grid
Minimum Tiles to Cover Grid
Minimum Tiles to Cover Grid
You are given a square grid of size M x M and a set of broken cells. The broken cells cannot be covered with tiles. Your task is to determine the minimum number of 1x1 tiles needed to cover all of the intact cells in the grid.
The answer is given by the formula:
$M^2 - B$
where $M^2$ represents the total number of cells in the grid and $B$ is the number of broken cells.
Note: The positions of the broken cells are given using 1-indexed row and column coordinates.
inputFormat
The first line of input contains two integers M and B, where M is the size of the grid and B is the number of broken cells.
The next B lines each contain two integers r and c, representing the row and column coordinates of a broken cell (1-indexed).
outputFormat
Output a single integer, which is the minimum number of 1x1 tiles required to cover all of the intact cells in the grid. This is computed as M2 - B.
## sample5 3
1 1
2 3
4 4
22
</p>