306458: CF1200D. White Lines
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
White Lines
题意翻译
给你两个整数**n**和**k**(1≤k≤n≤2000), 表示有一个n * n的正方形画布上只有黑点(B)和白点(W)。 用一块k * k的橡皮擦可以把画布上一个k * k的区域全部变成白色,即把黑色的部分擦除。 **白线**定义为一行或一列全都是白色(没有一块是黑色)的线。 问**只擦一次**画布上最多有多少条**白线**。 ——pxy1118翻译题目描述
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $ n $ rows and $ n $ columns of square cells. The rows are numbered from $ 1 $ to $ n $ , from top to bottom, and the columns are numbered from $ 1 $ to $ n $ , from left to right. The position of a cell at row $ r $ and column $ c $ is represented as $ (r, c) $ . 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 $ k $ ( $ 1 \le k \le n $ ). To use the eraser, Gildong needs to click on a cell $ (i, j) $ where $ 1 \le i, j \le n - k + 1 $ . When a cell $ (i, j) $ is clicked, all of the cells $ (i', j') $ where $ i \le i' \le i + k - 1 $ and $ j \le j' \le j + k - 1 $ become white. In other words, a square with side equal to $ k $ cells and top left corner at $ (i, j) $ 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 $ n $ and $ k $ ( $ 1 \le k \le n \le 2000 $ ) — the number of rows and columns, and the size of the eraser. The next $ n $ lines contain $ n $ characters each without spaces. The $ j $ -th character in the $ i $ -th line represents the cell at $ (i,j) $ . 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.
输入输出样例
输入样例 #1
4 2
BWWW
WBBW
WBBW
WWWB
输出样例 #1
4
输入样例 #2
3 1
BWB
WWB
BWB
输出样例 #2
2
输入样例 #3
5 3
BWBBB
BWBBB
BBBBB
BBBBB
WBBBW
输出样例 #3
2
输入样例 #4
2 2
BW
WB
输出样例 #4
4
输入样例 #5
2 1
WW
WW
输出样例 #5
4