#P3717. Grid Detection

    ID: 16968 Type: Default 1000ms 256MiB

Grid Detection

Grid Detection

Given an \(n\times n\) grid (with cells labeled starting from 1) and \(m\) detectors, each with a detection radius \(r\). A detector at \((a,b)\) can detect a grid point \((i,j)\) if the following condition holds:

\[ (i-a)^2 + (j-b)^2 \leq r^2 \]

Count the number of grid points that are detected by at least one detector.

Note: A grid point is considered detected if it satisfies the condition for any one of the detectors.

inputFormat

The input consists of multiple lines:

  • The first line contains three space-separated integers \(n\), \(m\), and \(r\), representing the grid size, the number of detectors, and the detection radius respectively.
  • Each of the next \(m\) lines contains two space-separated integers \(a\) and \(b\) indicating the coordinates of a detector.

outputFormat

Output a single integer representing the number of grid points that are detected by at least one detector.

sample

5 1 1
3 3
5