#C1507. Maximum Rectangle in a Binary Matrix
Maximum Rectangle in a Binary Matrix
Maximum Rectangle in a Binary Matrix
Given a binary matrix of size (N \times M), find the area of the largest rectangular sub-matrix that contains only ones. In other words, you are to compute the maximum number of cells that can form a rectangle consisting entirely of 1's. A rectangle's area is computed as its width multiplied by its height, i.e., (\text{Area} = \text{width} \times \text{height}).
The input consists of the number of rows and columns followed by the matrix elements. Your task is to print the maximum area found among all possible rectangles containing only ones.
inputFormat
The input is given via standard input (stdin). The first line contains two integers (N) and (M) separated by a space, representing the number of rows and columns respectively. This is followed by (N) lines, each containing (M) space-separated integers (each either 0 or 1), representing the matrix.
outputFormat
Output a single integer to standard output (stdout) that represents the area (number of cells) of the largest rectangle in the matrix that is comprised entirely of ones.## sample
4 4
0 1 1 0
1 1 1 1
1 1 1 1
1 1 0 0
8