#P1789. Monster Spawning in a Lightless Grid
Monster Spawning in a Lightless Grid
Monster Spawning in a Lightless Grid
In an \(n \times n\) grid, linyorson has placed \(m\) torches and \(k\) glowstones at specified coordinates. The torches illuminate cells in a diamond-shaped region defined by \(|x-i| + |y-j| \le 2\) with the torch located at \((i, j)\), while each glowstone illuminates all cells in a \(5 \times 5\) square centered on itself (i.e. for a glowstone at \((i, j)\), all cells with coordinates \(i-2 \le x \le i+2\) and \(j-2 \le y \le j+2\) are lit). A cell will spawn a monster if and only if it is not illuminated by any torch or glowstone and does not contain any of these items.
Given the positions of the torches and glowstones, determine the number of cells that spawn monsters.
inputFormat
The first line of input contains three integers \(n\), \(m\), and \(k\) representing the dimensions of the grid and the number of torches and glowstones, respectively.
The next \(m\) lines each contain two integers \(x\) and \(y\), giving the 1-indexed coordinates of each torch.
The following \(k\) lines each contain two integers \(o\) and \(p\), giving the 1-indexed coordinates of each glowstone.
outputFormat
Output a single integer representing the number of cells that will spawn monsters.
sample
5 1 0
3 3
12