QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100

#22742. Подсчёт прудов

统计

После дождей на поле Farmer John скопилась вода. Поле — прямоугольник $N \times M$ ($1 \le N \le 100$; $1 \le M \le 100$) клеток, каждая с водой ('$W$') или сухая ('.'). Он хочет число прудов. Пруд — связный набор водяных клеток, каждая соседствует со всеми восемью вокруг.

По схеме поля найдите число прудов.

Входные данные

  • Строка 1: два целых $N$, $M$ через пробел.

  • Строки $2..N+1$: по $M$ символов для ряда поля, каждый '$W$' или '.', без пробелов между ними.

Выходные данные

  • Строка 1: число прудов Farmer John.

Примеры

Входные данные 1

10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.

Выходные данные 1

3

Примечание

Пояснение

Три пруда: сверху слева, снизу слева и вдоль правой стороны.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.