QOJ.ac

QOJ

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

#22719. Figuras de fardos

Statistics

Vacas constroem figuras com $N$ ($1 \le N \le 25{,}000$) fardos cúbicos $1\times1\times1$.

Fardo 1 no chão; 2 até $N$ se unem sucessivamente em posição relativa a um já colocado. Exemplo:

Fardo 1 no chão.

Fardo 2 à direita de 1.

Fardo 3 à frente de 2.

Fardo 4 à frente de 3.

Resulta L invertido:

                     +--+--+

                1-> /  /  /| <-2

                   +--+--+ +

                   | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Acrescentar outro fardo:

Fardo 5 sobre fardo 1.

Aumenta altura:

                     +--+

                    /  /|

                   +--+ +--+

               5-> |  |/  /| <-2

                   +--+--+ +

               1-> | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Mas outra instrução:

Fardo 6 atrás de fardo 4.

Invalida figura, pois 3 e 6 se sobrepõem.

Dados $N$ fardos e posições, imprima área exposta se válida. Face exposta não toca face de outro nem chão (não base de cubo no chão). Inválida $-1$. Nenhum além de 25 larguras do primeiro nem abaixo do chão.

Entrada

  • Linha 1: inteiro $N$.

  • Linhas $2..N$: j X para fardos $2..N$, linha 2 fardo 2, linha 3 fardo 3 etc. X: L esquerda, R direita, F frente, B trás, O acima, U abaixo. Podem ser colados e sobre vazio não requerem apoio inferior.

Saída

  • Linha 1: área exposta ou -1 inválida.

Exemplos

Entrada 1

5
1 R
2 F
3 F
1 O

Saída 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.