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.