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.