#K84397. Maximal Rectangle in a Binary Matrix
Maximal Rectangle in a Binary Matrix
Maximal Rectangle in a Binary Matrix
You are given a binary matrix consisting of '0's and '1's. Your task is to find the area of the largest rectangle (composed entirely of '1's) in the matrix. A rectangle is defined as a contiguous block of cells in the matrix.
For example, consider the matrix below:
10100 10111 11111 10010
The largest rectangle of '1's in this matrix has an area of 6.
The area of a rectangle can be expressed using the formula: \( Area = width \times height \).
Write a program that reads the matrix from standard input and outputs the area of the largest rectangle formed by '1's.
inputFormat
The input is read from standard input (stdin) in the following format:
...
Here, n
is the number of rows in the matrix. Each of the following n
lines represents a row of the matrix and is a string consisting of characters '0' and '1'.
outputFormat
Output a single integer to standard output (stdout), representing the area of the largest rectangle that can be formed using only '1's.
## sample4
10100
10111
11111
10010
6