QOJ.ac

QOJ

実行時間制限: 2.5 s メモリ制限: 512 MB 満点: 100

#6474. 俄罗斯方块

統計

Sonya 正在翻找她的旧玩具。在积木和玩偶中,她找到了自己曾经爱玩的俄罗斯方块游戏。这个俄罗斯方块游戏非常特别,它有 10 种不同形状的方块,以及一个宽为 3、高为 10 的网格。你可以将游戏想象成一个无限的方块流,其中一个序列 $a$ 被不断重复。

她决定玩这个游戏。在方块下落前,Sonya 可以将其旋转 90 度的整数倍,但不能将其翻转。如果某一行被填满,该行就会消失,其上方的所有行会下落,并在最上方空出一行。当网格中没有空间容纳下一个方块时,游戏结束。

现在的 Sonya 变得更聪明了,她想在游戏结束前最大化下落的方块数量。游戏也可能永远不会结束。在这种情况下,你应该告诉 Sonya 不要开始玩这个游戏。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 50$),表示序列 $a$ 的长度。 第二行包含 $n$ 个整数 $a_i$ ($0 \le a_i \le 9$),表示序列 $a$ 的元素。

输出格式

输出一个数字,表示游戏结束前能落下的最大方块数量;如果可以一直玩下去并获得无限数量的方块,则输出 -1。

样例

输入格式 1

1
0

输出格式 1

4

输入格式 2

2
3 4

输出格式 2

12

输入格式 3

3
5 1 1

输出格式 3

-1

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.