#K92662. Maximum Rectangle in a Binary Matrix

    ID: 38248 Type: Default 1000ms 256MiB

Maximum Rectangle in a Binary Matrix

Maximum Rectangle in a Binary Matrix

Given a binary matrix with m rows and n columns filled with 0's and 1's, find the area \(A\) of the largest rectangle containing only 1's. The rectangle's area is given by \(A = height \times width\). If the matrix is empty or contains no 1's, the answer is 0.

Your task is to compute this maximum area based on the input matrix.

inputFormat

The input is provided via standard input (stdin) with the following format:

  • The first line contains two integers \(m\) and \(n\), representing the number of rows and columns respectively.
  • Each of the next \(m\) lines contains \(n\) space-separated integers (either 0 or 1) indicating a row of the matrix.

outputFormat

Output a single integer to standard output (stdout) representing the area of the largest rectangle consisting solely of 1's.

## sample
4 4
1 0 1 0
1 0 1 1
1 1 1 1
1 0 0 0
4