QOJ.ac

QOJ

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

#22719. Figuras de fardos

Statistics

Las vacas construyen figuras con $N$ ($1 \le N \le 25{,}000$) fardos cúbicos $1\times1\times1$.

Fardo 1 en suelo; 2 hasta $N$ se unen sucesivamente por posición relativa a otro ya puesto. Ejemplo:

Fardo 1 en suelo.

Fardo 2 a derecha de 1.

Fardo 3 delante de 2.

Fardo 4 delante de 3.

Resulta L invertida:

                     +--+--+

                1-> /  /  /| <-2

                   +--+--+ +

                   | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Añadir otro fardo:

Fardo 5 sobre fardo 1.

Añade altura:

                     +--+

                    /  /|

                   +--+ +--+

               5-> |  |/  /| <-2

                   +--+--+ +

               1-> | /  /|/

                   ++--+ +

                   /  /|/ <-3

                  +--+ +

                  |  |/ <-4

                  +--+

Pero otra orden:

Fardo 6 detrás de fardo 4.

Invalida figura, pues 3 y 6 se solapan.

Dados $N$ fardos y posiciones, imprime área expuesta si válida. Cara expuesta no toca cara de otro fardo ni suelo (no fondo del cubo en suelo). Si inválida $-1$. Ninguno más lejos de 25 anchos del primero ni bajo suelo.

Entrada

  • Línea 1: entero $N$.

  • Líneas $2..N$: j X describe fardos $2..N$, línea 2 fardo 2, línea 3 fardo 3, etc. X: L izquierda, R derecha, F delante, B detrás, O encima, U debajo. Se pegan y sobre hueco no requieren soporte inferior.

Salida

  • Línea 1: área expuesta o -1 inválida.

Ejemplos

Entrada 1

5
1 R
2 F
3 F
1 O

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