Fields

A rectangular field of size m × n contains mn square areas. Some of the
areas are occupied by a determinated growing (tomatoes, carrots, etc.)
that is identified by a natural number strictly positive. It is known
that growings are grouped in different disjointed rectangles and that a
growing always is separated of another one by areas without grownings,
identify by the value 0.

Write a program that reads fields and prints the number of rectangular
growings.

Input

Input consists in a sequence of fields. For each field, it is given two
natural numbers m and n with m ≥ 1 and n ≥ 1 that represent the size of
the field. Then, it is given m rows, each one with n natural numbers
that represent the growing of the area. The fields follow the hypotheses
described previously.

Output

For each fielf of the input, print in a line the number of rectangular
growings.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:19:30.004Z

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