QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 256 MB 満点: 100

#22742. Contare stagni

統計

Le piogge recenti hanno raccolto acqua nel campo di Farmer John, rettangolo di $N \times M$ ($1 \le N \le 100$; $1 \le M \le 100$) celle. Ognuna è acqua ('$W$') o terra asciutta ('.'). Vuole contare stagni. Uno stagno è un insieme connesso di celle d’acqua, ogni cella adiacente a tutte le otto attorno.

Dato il disegno del campo, conta stagni.

Input

  • Riga 1: due interi $N$, $M$ separati da spazio.

  • Righe $2..N+1$: $M$ caratteri per riga, ciascuno '$W$' o '.', senza spazi fra loro.

Output

  • Riga 1: numero di stagni nel campo di Farmer John.

Esempi

Input 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.

Output 1

3

Note

Spiegazione

Tre stagni: in alto a sinistra, in basso a sinistra e lungo il lato destro.

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.