#C11448. Maximum Stars in a Subgrid
Maximum Stars in a Subgrid
Maximum Stars in a Subgrid
You are given a night sky represented as a grid of characters. Each cell in the grid is either a star (denoted by '*') or an empty space (denoted by '.'). Your task is to find a subgrid of fixed dimensions that contains the maximum number of stars. A subgrid is a contiguous rectangular section of the original grid. This problem requires you to slide the window over the grid and count the stars in each subgrid. Finally, output the maximum number of stars found in any such subgrid.
inputFormat
The input is given via standard input. The first line contains four space-separated integers , , , and , where and denote the number of rows and columns in the grid respectively, and and denote the dimensions of the subgrid. This is followed by lines, each containing a string of length representing a row of the grid. In these strings, '*' represents a star and '.' represents an empty cell.
outputFormat
Print a single integer to standard output: the maximum number of stars contained in any subgrid of the grid.## sample
5 5 2 2
*.*..
..*.*
*....
..*.*
*..**
3