#C423. Maximal Rectangle

    ID: 47745 Type: Default 1000ms 256MiB

Maximal Rectangle

Maximal Rectangle

You are given a 2D binary matrix filled with characters '0' and '1'. Your task is to find the area of the largest rectangle containing only '1's and return its area.

Note: The rectangle must be contiguous and formed by adjacent cells in the matrix.

In mathematical terms, given a matrix A of size \( m \times n \), find the maximum area \( A_{max} = h \times w \) such that there exists a submatrix of A with height \( h \) and width \( w \) consisting entirely of '1's.

Input/Output: The input is read from standard input, and the output should be written to standard output.

inputFormat

The first line contains two integers \( m \) and \( n \) representing the number of rows and columns of the matrix respectively. \( (0 \le m, n \le 1000) \).

Each of the next \( m \) lines contains a binary string of length \( n \) consisting of characters '0' or '1'. If \( m = 0 \), the matrix is considered empty.

outputFormat

Output a single integer representing the area of the largest rectangle containing only '1's.

## sample
4 5
10100
10111
11111
10010
6