White Lines
시간 제한1.5초메모리 제한256 MB
n x n 흑백 격자에서 k x k 정사각형 하나를 지워 완전히 흰색이 되는 행과 열의 수를 최대로 만든다.
문제
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of rows and columns of square cells. The rows are numbered from to , from top to bottom, and the columns are numbered from to , from left to right. The position of a cell at row and column is represented as . There are only two colors for the cells in cfpaint --- black and white.
There is a tool named eraser in cfpaint. The eraser has an integer size (). To use the eraser, Gildong needs to click on a cell where . When a cell is clicked, all of the cells where and become white. In other words, a square with side equal to cells and top left corner at is colored white.
A white line is a row or a column without any black cells.
Gildong has worked with cfpaint for some time, so some of the cells (possibly zero or all) are currently black. He wants to know the maximum number of white lines after using the eraser exactly once. Help Gildong find the answer to his question.
입력
The first line contains two integers and () --- the number of rows and columns, and the size of the eraser.
The next lines contain characters each without spaces. The -th character in the -th line represents the cell at . Each character is given as either ‘B’ representing a black cell, or ‘W’ representing a white cell.
출력
Print one integer: the maximum number of white lines after using the eraser exactly once.
힌트
In the first example, Gildong can click the cell , then the working screen becomes:
BWWW
WWWW
WWWW
WWWB
Then there are four white lines --- the -nd and -rd row, and the -nd and -rd column.
In the second example, clicking the cell makes the -nd row a white line.
In the third example, both the -nd column and -th row become white lines by clicking the cell .