#K7741. Maximum Product Contiguous Submatrix

    ID: 34858 Type: Default 1000ms 256MiB

Maximum Product Contiguous Submatrix

Maximum Product Contiguous Submatrix

You are given a matrix of integers with dimensions n by m. Your task is to find the maximum product of elements in any contiguous submatrix of the given matrix. A contiguous submatrix is defined by choosing a top-left corner at position \((i, j)\) and a bottom-right corner at position \((k, l)\) such that \(0 \le i \le k < n\) and \(0 \le j \le l < m\). The product is computed by multiplying all the elements inside the submatrix.

Note: The matrix may contain negative numbers and zeros, so take care when determining the maximum product.

inputFormat

The first line of the input contains two integers \(n\) and \(m\) (\(1 \le n, m \le 50\)), representing the number of rows and columns of the matrix, respectively. Each of the next \(n\) lines contains \(m\) space-separated integers representing the elements of the matrix.

outputFormat

Output a single integer which is the maximum product achievable by any contiguous submatrix of the given matrix.

## sample
3 3
1 -2 3
4 -1 2
-1 -3 0
48