QOJ.ac

QOJ

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

#22719. Figuren aus Ballen

Statistics

Kühe bauen Figuren aus $N$ ($1 \le N \le 25{,}000$) würfelförmigen Ballen $1\times1\times1$.

Ballen 1 liegt auf dem Boden; 2 bis $N$ werden nacheinander relativ zu einem schon gesetzten Ballen angefügt. Beispiel:

Ballen 1 auf Boden.

Ballen 2 rechts von 1.

Ballen 3 vor 2.

Ballen 4 vor 3.

Das ergibt ein umgekehrtes L:

                     +--+--+

                1-> /  /  /| <-2

                   +--+--+ +

                   | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Weiterer Ballen:

Ballen 5 über Ballen 1.

Erhöht die Figur:

                     +--+

                    /  /|

                   +--+ +--+

               5-> |  |/  /| <-2

                   +--+--+ +

               1-> | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Aber weitere Anweisung:

Ballen 6 hinter Ballen 4.

Macht ungültig, da 3 und 6 überlappen.

Für $N$ Ballen und Platzierungen gib die freie Oberfläche aus, falls gültig. Frei heißt keine andere Ballenfläche und kein Boden berührt sie (nicht Würfelunterseite auf Boden). Ungültig: $-1$. Kein Ballen weiter als 25 Ballenbreiten vom ersten oder unter Boden.

Eingabe

  • Zeile 1: ganze Zahl $N$.

  • Zeilen $2..N$: j X beschreibt Ballen $2..N$, Zeile 2 Ballen 2, Zeile 3 Ballen 3 usw. X: L links, R rechts, F vorne, B hinten, O darüber, U darunter. Sie können geklebt sein, über Leerraum ohne Unterstützung.

Ausgabe

  • Zeile 1: freie Oberfläche oder -1 ungültig.

Beispiele

Eingabe 1

5
1 R
2 F
3 F
1 O

Ausgabe 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.