QOJ.ac

QOJ

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

#21229. 三次元宇宙探査

Statistics

Farmer John の牛たちはついに地球から飛び立ち、Moocraft で宇宙を漂っています。木星の衛星 Io の燃えるような親戚に会いたいのですが、まず危険な小惑星帯を抜けなければなりません。

Bessie が操縦し、危険な $N \times N \times N$ の宇宙区画を通ります。$1 \le N \le 100$ です。小惑星は $1 \times 1 \times 1$ の岩石ブロックが面で接してできています(頂点だけ、辺だけで接する二つは別の小惑星です)。

区画内の異なる小惑星の数を数えて助けてください。

$3 \times 3 \times 3$ の空間の最初の断面を下図に示します。$M$ は Moocraft の出発点 $(1,1,1)$、D は目的地 $(3,3,3)$ です。主に地図の向きを示す目印で、解くための有用な情報ではありません。

図と入力では * が小惑星のブロック、. が広大な空の空間です。

   近い断面       中央の断面       遠い断面      重ねて組み立て
     +---+            +---+          +---+                  +---+ 遠
     |M..|            |..*|          |...|                  |...|
     |.*.|            |.*.|          |.*.|                +---+.|
     |...|            |*..|          |..D|                |..*|D|
     +---+            +---+          +---+              +---+.|-+
                                                        |M..|.|
                                                        |.*.|-+
                                                        |...|
                                                     近 +---+

見ると三つの小惑星があり、一つは中央を貫く長いものです。ブロックに番号を付けた図を示します。

                                  +---+ 遠
                                 /|...|
                                / |.1.|
                               /  |...|
                              /   +---+
                             +---+   /
                            /|..3|  /  
                           / |.1.| /
                          /  |2..|/
                         /   +---+
                        +---+   /
                        |...|  /
                        |.1.| /
                        |...|/
                     近 +---+

入力

  • 1 行目:整数 $N$。
  • $2..N^2+1$ 行目:$i-1$ 行目は断面 $\operatorname{int}((i+N-1)/N)$ の $1 + ((k+1)\%N)$ 行目で、$N$ 文字です。

出力

  • 1 行目:区画の小惑星数を示す整数一つ。

入出力例

入力 1

3
...
.*.
...
..*
.*.
*..
...
.*.
...

出力 1

3

問題作成者:Andre Kessler、2010

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.