QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22752. 衛星写真

Statistics

Farmer John は良い農場地図が欲しく、土地の衛星写真を購入しました。$R$ 行($1 \le R \le 75$)、$C$ 列($1 \le C \le 75$)です。一部は次のようです:

..................
..#####.......##..
..#####......##...
..................
#.......###.....#.
#.....#####.......

各連結形状は納屋か牛と解釈します。連結形状とは縦横に隣接する一つ以上の '#' の集合です。次は二つの別形状:

....
.#..
..#.
....

FJ は中の埋まった矩形で四辺が $x$、$y$ 軸に平行な形状を納屋とします。最初の図は3納屋($2\times1$、$2\times5$、$1\times1$)、2牛です(牛の大きさに驚くでしょう!)。写真の納屋と牛を数えてください。

牛は他の牛や納屋を完全には囲みません。

入力

  • 1行目:空白区切り2整数 $R$、$C$。
  • $2$ から $R+1$ 行目:$i+1$ 行目は写真の $i$ 行を表し、$C$ 文字、空白なし。

出力

  • 1行目:納屋数。
  • 2行目:牛数。

入出力例

入力 1

5 8
#####..#
#####.##
......#.
.###...#
.###..##

出力 1

2
2

注記

入力説明

写真5行、各8文字。

出力説明

2納屋(左の形状)、2牛(右)。

問題作成者:Brian Dean, 2004

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.