#C14146. Maximum Rectangle in a Binary Matrix
Maximum Rectangle in a Binary Matrix
Maximum Rectangle in a Binary Matrix
Given a 2D binary matrix filled with '0's and '1's, find the area of the largest rectangle containing only '1's. This problem requires you to process the matrix and determine the maximum possible area formed by contiguous '1's.
Note: If the matrix is empty, the result should be 0. The rectangle must have sides parallel to the matrix axes.
You can use the following mathematical formulation: If a rectangle has height \(h\) and width \(w\), its area is given by \(A = h \times w\).
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(n\) which represents the number of rows in the matrix. If \(n = 0\), the matrix is empty.
- If \(n > 0\), each of the next \(n\) lines contains space-separated characters (each character is either '0' or '1') representing a row of the matrix. All rows have the same number of elements.
outputFormat
Output a single integer which is the area of the largest rectangle consisting of only '1's. The output is written to standard output (stdout).
## sample1
1
1
</p>