QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB Toplam puan: 100

#22742. 池を数える

İstatistikler

最近の雨で Farmer John の畑に水たまりができました。畑は $N \times M$ ($1 \le N \le 100$; $1 \le M \le 100$) マスの長方形で、各マスは水('$W$')か乾いた地面('.')。池の数を知りたいです。池は水のマスの連結集合で、周囲8マスすべてを隣接とします。

畑の図から池数を求めてください。

入力

  • 1行目:空白区切り2整数 $N$、$M$。

  • $2..N+1$ 行目:各行 $M$ 文字で畑の1行、各文字 '$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

注記

説明

池は左上、左下、右側の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.