Subsquares in a matrix

Given an n × m matrix of numbers between 1 and 9, compute how many
subsquares 3 × 3 it has with all the numbers between 1 and 9.

Input

Input consists of several cases. Every case begins with n and m,
followed by an n × m matrix of integer numbers between 1 and 9. Suppose
that n and m are between 3 and 100.

Output

For every matrix, print the number of subsquares 3 × 3 that have all the
numbers between 1 and 9.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T15:15:27.921Z

© Jutge.org, 2006–2026.
https://jutge.org
