Given a matrix with digits 1, 2, …, 9, you must count how many submatrices of size of the given matrix contain all different digits 1, 2, …, 9.
The input has several cases. Each one starts with two positive natural numbers in the first line. Afterwards comes a matrix of size with digits 1, 2, …, 9 ( lines with digits each).
For each case, the program must write in a new line the number of submatrices inside of which all digits 1, 2, …, 9 appear.
There is no need to optimize this problem. Any reasonably efficient implementation will pass.
Evaluation over 10 points:
Passes public test cases: 5 points.
Passes public and private test cases: 10 points.
Author: PRO1
Generation: 2026-01-25T21:58:13.204Z
© Jutge.org, 2006–2026.
https://jutge.org