IntuitOA #22
Spreading Fire (Intuit India)
EasyJudge-ready
Topics (AI-labelled)Bits & MathSimulation
There are K burning lattice points in a rectangular plane. Fire spreads outward from each origin as a circle: at t=1 the radius is R, and it grows by R every unit of time after that. Find the number of integer lattice points not touched by any fire at time T.
Input
The first line contains N M K; the next K lines contain fire coordinates x y; the last line contains R T. Per the problem's example, the integer lattice points include the boundary, i.e., 0≤x≤N, 0≤y≤M. Site limits: 1≤N,M≤100, 1≤K≤100, 0≤R,T≤100, and every fire coordinate lies within the lattice range above.
Output
Output the number of integer lattice points not touched by fire. A point whose distance to any fire is less than or equal to R×T counts as touched.
Example 1
Input:
4 4 2
1 1 3 3
1 2
Output:
6
Example 2
Input:
1 1 1
0 0
1 1
Output:
1
Example 3
Input:
1 1 1
0 0
0 10
Output:
3
Example notes
The boundary points enumerated in the problem's example show that the plane has (N+1)×(M+1) integer lattice points in total; points on a circle also count as touched. This site added input ranges to keep the enumeration time manageable.
Editorial
Loading solution…