You are given a rectangular battlefield represented as an n × m grid and an integer k.
A tower placed on cell (r, c) can cover all cells whose Chebyshev distance from (r, c) is at most k.
The Chebyshev distance between two cells (r1, c1) and (r2, c2) is defined as:
distance=max(∣r1−r2∣,∣c1−c2∣)
Your task is to find the minimum number of towers required to cover every cell in the battlefield grid.
Input: n = 7 m = 5 k = 1
Output: 6
Input: n = 6 m = 6 k = 2
Output: 4
Accepted:
Submission: