LearnPy Hub
← Arena
IntermediateRating 1400

Count Squares of Ones

Count every square block (any size) in the 0/1 grid that is made only of 1s.

Input

r and c, then r rows of 0s and 1s separated by spaces.

Output

One integer.

Sample 1

Input
3 4
0 1 1 1
1 1 1 1
0 1 1 1
Output
15

Sample 2

Input
3 3
1 0 1
1 1 0
1 1 0
Output
7
solution.py
Output appears here
Count Squares of Ones · Python Arena problem · LearnPy Hub