#P10719. [GESP202406 五级] 黑白格

[GESP202406 五级] 黑白格

Background

Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1153.

Problem Description

Xiao Yang has a grid with nn rows and mm columns, where each cell is either white or black.

Xiao Yang wants to know how many cells are contained in the smallest sub-rectangle that contains at least kk black cells.

Input Format

The first line contains three positive integers n,m,kn, m, k, with meanings as described in the statement.

Then follow nn lines, each containing a 01\texttt{01} string of length mm, representing the colors of the cells in row ii of the grid. If it is 0\texttt{0}, the corresponding cell is white; otherwise, it is black.

Output Format

Output one integer, representing the number of cells contained in the smallest sub-rectangle that contains at least kk black cells. If it does not exist, output 00.

4 5 5
00000
01111
00011
00011
6

Hint

Sample Explanation

For sample 11, let (i,j)(i, j) represent row ii and column jj. The four vertices of the smallest sub-rectangle that contains at least 55 black cells are (2,4)(2, 4), (2,5)(2, 5), (4,4)(4, 4), (4,5)(4, 5), and it contains a total of 66 cells.

Constraints

For all data, it is guaranteed that 1n,m1001 \le n, m \le 100 and 1kn×m1 \le k \le n \times m.

Subtask ID Score n,mn, m
11 2020 10\le 10
22 4040 n=1n = 1, 1m1001 \le m \le 100
33 100\le 100

Update on 2024/7/9: Several groups of hack testdata were added. Thanks to @cff_0102 for the contribution.

Translated by ChatGPT 5