#K9166. Maximal Rectangle in a Binary Matrix
Maximal Rectangle in a Binary Matrix
Maximal Rectangle in a Binary Matrix
Given a binary matrix filled with '0's and '1's, find the area of the largest rectangle containing only '1's. The rectangle should be formed by contiguous rows and contiguous columns.
The input is provided via standard input. Each line represents a row in the matrix with space-separated values. Your task is to compute and output the maximal area of any rectangle composed entirely of '1's.
For example, consider the following matrix:
1 0 1 0 1 0 1 1 1 1 1 1 1 0 0 1
The largest rectangle of 1's in this matrix has an area of 4.
Solve this problem by reading input from stdin and printing the result to stdout.
inputFormat
The input is read from stdin and consists of multiple lines. Each non-empty line represents a row of the binary matrix with its entries separated by spaces. There is no explicit size given; you should read until end-of-file.
outputFormat
Output a single integer representing the maximum area of a rectangle composed entirely of '1's. The result should be printed to stdout.
## sample1 0 1 0
1 0 1 1
1 1 1 1
1 0 0 1
4