-
Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John would like to figure out how many ponds have formed in his field. A pond is a connected set of squares with water in them, where a square is considered adjacent to all eight of its neighbors.
Given a diagram of Farmer John's field, determine how many ponds he has.
Lake Counting(数湖)
Description(描述)
翻译:
由于最近的降雨,水已经在农民约翰的农场中的各个地方聚集,这是由N×M(1 <= N <= 100; 1 <= M <= 100)正方形的矩形表示的。 每个正方形包含水('W')或干地('.')。农民约翰想知道在他的农场已经形成了多少个池塘。 一个池塘是一组连接在一起的水,一个包含水正方形被认为与其邻近的八个方向相邻。
给出了约翰农场的图表,确定他的农场里有多少池塘。
-
* Line 1: Two space-separated integers: N and M
*Lines 2..N+1: M characters per line representing one row of Farmer John's field. Each character is either 'W' or '.'. The characters do not have spaces between them.
Input(输入)
翻译:
-
*行1:两个空格分隔的整数:N和M
*行2..N + 1: 每行代表一行农民约翰的字段的M 个字符。 每个字符都是“W ”或“ .”。 字符之间没有空格。
Output(输出)
* Line 1: The number of ponds in Farmer John's field.
翻译:
- *行1:农民约翰的田野中的池塘数。