Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Create an additive table that counts the sum of elements of submatrix with the superior corner at (0,0).
Loop over all subsquares in O(n^3) and check if the sum make the whole array to be ones, if it checks then add 1 to the answer.