Problem D
Artwork
A template for an artwork is a white grid of
The beauty of an artwork is the number of regions in the
grid. Each region consists of one or more white squares that
are connected to each other using a path of white squares in
the grid, walking horizontally or vertically but not
diagonally. The initial beauty of the artwork is
![\includegraphics[width=0.9\textwidth ]{sample}](/problems/artwork/file/statement/en/img-0001.png)
Input
The first line of input contains three integers
Then follow
Output
For each of the
Sample Input 1 | Sample Output 1 |
---|---|
4 6 5 2 2 2 6 1 3 4 3 2 5 3 5 4 6 4 6 1 6 4 6 |
1 3 3 4 3 |