You’re one of the developers of the Sea Battle game. Now you are responsible for updating one of the most important statistics in the game - given a board you should find out the number of
woundedships. You know that:
- No ships share a side. So, if two neighbor cells in a grid are marked as part of a ship, then it’s the same ship.
- In this game, the ships don’t necessarily form a straight line. This is an advanced mode of a game available for premium users.
- If no bombs were dropped on a ship, then the ship is
- If all the cells of the ship are bombed, then the ship is
- If only some cells are bombed, the ship is considered to be
You should write a program that given a grid of the current situation would print the number of
The first line of the input contains two characters
c(1 ≤ r, c ≤ 50) - rows and columns of the grid.
ccolumns of characters representing the grid:
.represents water (no ship)
srepresents a healthy ship cell
brepresents a bombed ship cell
The program should print 3 numbers - the number of
Input 7 8 ..s.bb.s s....... s.sssss. b.s...s. ..sssbs. s....... ss......
Output 3 1 2
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB