QOJ.ac

QOJ

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

#22719. צורות חבילות

Statistics

פרות בונות צורות מ־$N$ ($1 \le N \le 25{,}000$) חבילות קובייתיות $1\times1\times1$.

חבילה 1 ברצפה; 2 עד $N$ מחוברות לפי הסדר במיקום יחסי לחבילה קיימת. למשל:

חבילה 1 ברצפה.

2 מימין ל־1.

3 לפני 2.

4 לפני 3.

נוצר L הפוך:

                     +--+--+

                1-> /  /  /| <-2

                   +--+--+ +

                   | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

הוספת חבילה:

חבילה 5 מעל 1.

מוסיפה גובה:

                     +--+

                    /  /|

                   +--+ +--+

               5-> |  |/  /| <-2

                   +--+--+ +

               1-> | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

אבל הוראה נוספת:

חבילה 6 מאחורי 4.

מבטלת כי 3 ו־6 חופפות.

נתונות $N$ חבילות ומיקומן; הדפיסו שטח חשוף אם תקין. פאה חשופה אינה נוגעת בפאה אחרת או ברצפה (אינה תחתית קובייה ברצפה). לא תקין $-1$. שום חבילה רחוקה יותר מ־25 רוחבי חבילה מהראשונה או מתחת לרצפה.

קלט

  • שורה 1: שלם $N$.

  • שורות $2..N$: j X לחבילות $2..N$, שורה 2 לחבילה 2, 3 לחבילה 3 וכן הלאה. X: L שמאל, R ימין, F קדימה, B אחורה, O מעל, U מתחת. ניתן להדביק ולתלות מעל חלל ללא תמיכה מלמטה.

פלט

  • שורה 1: שטח חשוף או -1 אם לא תקין.

דוגמאות

קלט 1

5
1 R
2 F
3 F
1 O

פלט 1

18

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.