#K4951. Maximal Rectangle
Maximal Rectangle
Maximal Rectangle
Given a binary matrix filled with 0's and 1's, your task is to find the largest rectangle containing only 1's and return its area. For a rectangle with height \(h\) and width \(w\), its area is given by \(A = h \times w\).
The matrix will be provided via standard input (stdin), and you should output the result to standard output (stdout).
inputFormat
The first line contains an integer (n) representing the number of rows in the matrix. If (n > 0), the next (n) lines each contain space-separated integers (either 0 or 1) which denote the row elements. All rows are guaranteed to have the same number of columns. If (n = 0), the matrix is empty.
outputFormat
Output a single integer: the area of the largest rectangle that contains only 1's.## sample
4
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
6