#C11448. Maximum Stars in a Subgrid

    ID: 40765 Type: Default 1000ms 256MiB

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 a×ba \times b 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 a×ba \times b 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 mm, nn, aa, and bb, where mm and nn denote the number of rows and columns in the grid respectively, and aa and bb denote the dimensions of the subgrid. This is followed by mm lines, each containing a string of length nn 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 a×ba \times b subgrid of the grid.## sample

5 5 2 2
*.*..
..*.*
*....
..*.*
*..**
3