QOJ.ac

QOJ

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

#22719. Figury z bel

Statistics

Krowy budują figury z $N$ ($1 \le N \le 25{,}000$) sześciennych bel $1\times1\times1$.

Bela 1 na podłodze; 2 do $N$ kolejno dołączone względem już ustawionej. Na przykład:

Bela 1 na podłodze.

Bela 2 na prawo od 1.

Bela 3 przed 2.

Bela 4 przed 3.

Odwrócone L:

                     +--+--+

                1-> /  /  /| <-2

                   +--+--+ +

                   | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Dodajmy belę:

Bela 5 nad belą 1.

Zwiększa wysokość:

                     +--+

                    /  /|

                   +--+ +--+

               5-> |  |/  /| <-2

                   +--+--+ +

               1-> | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Ale następna instrukcja:

Bela 6 za belą 4.

Unieważnia, bo 3 i 6 nakładają się.

Dla $N$ bel i pozycji wypisz odsłoniętą powierzchnię, jeśli poprawne. Ściana odsłonięta nie dotyka ściany innej beli ani podłogi (nie dół kostki na podłodze). Niepoprawne $-1$. Żadna dalej niż 25 szerokości od pierwszej ani poniżej podłogi.

Wejście

  • Wiersz 1: całkowita $N$.

  • Wiersze $2..N$: j X dla bel $2..N$, wiersz 2 bela 2, wiersz 3 bela 3 itd. X: L lewo, R prawo, F przód, B tył, O nad, U pod. Można skleić, nad pustką nie potrzeba dolnego podparcia.

Wyjście

  • Wiersz 1: odsłonięta powierzchnia lub -1 niepoprawne.

Przykład

Wejście 1

5
1 R
2 F
3 F
1 O

Wyjście 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.