#B4264. Counting Good 2x2 Submatrices
Counting Good 2x2 Submatrices
Counting Good 2x2 Submatrices
You are given a matrix \(A\) of size \(n \times m\). A \(2 \times 2\) submatrix \(D\) of \(A\) (formed by choosing two consecutive rows and two consecutive columns) is called good if and only if it satisfies the condition:
\(D_{1,1} \times D_{2,2} = D_{1,2} \times D_{2,1}\)
where \(D_{i,j}\) denotes the element in the \(i\)-th row and \(j\)-th column of submatrix \(D\). Your task is to count the number of good \(2 \times 2\) submatrices in the matrix \(A\).
inputFormat
The first line contains two integers \(n\) and \(m\) representing the number of rows and columns of the matrix \(A\), respectively.
Each of the following \(n\) lines contains \(m\) integers representing the elements of the matrix \(A\).
outputFormat
Output a single integer, the number of good \(2 \times 2\) submatrices in the matrix \(A\).
sample
2 2
1 2
3 6
1
</p>