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$ מכילה שורה $1 + ((k+1)\%N)$ של חתך $\operatorname{int}((i+N-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.