QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#22356. まずい草

Estadísticas

Bessie は柔らかい草の芽を食べながら、牛らしく宇宙について考えていました。農場の基準高度にある広い牧草地の草だけがおいしいと気付きました。たった 1 メートル高い草も硬くて食欲をそそりません。高くなるほど草はまずくなります。

食べ続けながら、まずい草は丘の斜面に生え、柔らかく緑豊かでおいしい草の海の中に「島」を作っていると気付きました。

白衣を着た Bessie は、まずい草の島の数を調べると決めました。牧草地を $R$ 行($1 \lt R \le 1,000$)、$C$ 列($1 \lt C \le 1,000$)の $1 \times 1$ メートルのマスに分けた地図を作り、基準からの高さを測って非負整数に丸めました。おいしい草の高さはすべて 0 だと、空腹の彼女は気付きました。

島を数え始めました。水平、垂直または対角方向に隣接する 2 マスは同じ島の一部とみなします。

与えられた各地図について、まずい草の島はいくつありますか。

入力

  • 1 行目:空白区切りの整数 $R$ と $C$。

  • $2,\ldots,R+1$ 行目:$i+1$ 行目に、地図の第 $i$ 行を表す $C$ 個の空白区切り整数があります。

出力

  • 1 行目:島の数を表す整数。

入出力例

入力 1

8 7
4 3 2 2 1 0 1
3 3 3 2 1 0 1
2 2 2 2 1 0 0
2 1 1 1 1 0 0
1 1 0 0 0 1 0
0 0 0 1 1 1 0
0 1 2 2 1 1 0
0 1 1 1 2 1 0

出力 1

2

注記

島は 2 つです。左の大きな島は対角線でつながり底まで伸び、右上には小さな島があります。

問題作成:Fatih, 2008

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.