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.