#P1331. Counting Square Ships
Counting Square Ships
Counting Square Ships
On a square board, a fixed number of ships are placed. Each ship is composed of adjacent '#' characters forming a perfect square, and no two ships touch each other (i.e. they do not share edges or corners). Your task is to count the total number of ships on the board.
The board is given as an n×n grid. Each cell is either '#' representing a part of a ship or '.' representing water. It is guaranteed that every ship forms a square shape.
Note: Ships do not contact one another.
inputFormat
The first line contains an integer n, the size of the board (n x n). The following n lines each contain exactly n characters (each either '#' or '.') representing the board.
outputFormat
Output a single integer that is the total number of ships on the board.
sample
5
.....
.##..
.##..
.....
.....
1