#T107. Lake Counting
Lake Counting
Description
Problem Statement: There is an N×M plot of land where water has accumulated after the rain. Water is marked as 'W', and dry areas are marked as '.'. Puddles connected in eight directions (horizontally, vertically, and diagonally) are considered part of the same water puddle. Determine the total number of distinct water puddles in the yard.
Input Format
The first line contains two integers, N and M (1 ≤ N, M ≤ 110).
The following N lines represent the land diagram, each consisting of M characters ('W' or '.').
Output Format
A single line containing the total number of water puddles.
10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.
3