#P14996. [Nordic OI 2020] Bricks
[Nordic OI 2020] Bricks
题目描述
Josefine is playing a tetris like game called bricks. The game takes place in a rectangular grid with columns rows. A brick takes up a slot in the grid. Initially the grid is empty. A brick formation is a rectangle where some parts are filled with bricks and the rest is air. The following is an example of a brick formation where # represents bricks and _ represents air:
#_##
##__
#__#
The game takes place in rounds. In each round, the player is shown a brick formation that she must decide where (horizontally) to drop from the top of the grid. When dropping a brick formation, each brick will independently fall down in a vertical line, and land either on the bottom of the grid or directly on top of another brick (from the same formation or from earlier rounds). Since the bricks fall independently, there will be no air holes between bricks in a column afterwards (this is unlike tetris). Before dropping the brick formation, the player may rotate it 0, 90, 180, or 270 degrees. The brick formation must be dropped such that all bricks land within the grid.
In the end of each round, all columns in the grid with at least 3 bricks will collapse and the bricks are thereby removed from the grid. A round has an associated round score . Let be the number of collapsed bricks in a round , the player then gets points in that round.
The goal of the game is to maximize the score over all rounds (ie. maximize ). Help Josefine by writing a program that given the brick formations and round scores computes the maximum possible score one can get.
输入格式
- Line 1: The number of rounds ().
- For each round:
- Next line: The integers where is the dimensions of the th brick formation, and is the round score ( and ).
- Next lines: The brick formation represented as a rectangle of
#'s and_'s where#represent bricks and_represent air. (the rectangle will always be the smallest possible rectangle that covers all bricks in the formation)
输出格式
- Line 1: The maximum possible score.
3
2 2 10
#_
##
3 2 4
#_#
_#_
3 3 2
#_#
###
#__
30
提示
If we simply drop the first brick formation as long to the left as possible without rotating it we get:
______
______
______
______
______
______
#_____
##____
If we then rotate the second brick formation 90 degrees counter clockwise. And drop it as long to the left as possible we get: (Xs marking collapsed bricks - they will be gone when the next round starts).
______
______
______
______
X_____
X_____
X#____
X#____
Since the round score in round 2 is 4, we obtain points from this. Finally, we rotate the last brick formation 180 degrees, and drop it second most to the left, we get:
______
______
______
______
_X____
_X_X__
_X_X__
_X#X__
The last round score is and thus we obtain points in this round. In total we got points. This is optimal.
Scoring
Your solution will be tested on a set of test case groups. To get the points for a group, you need to pass all the test cases in the group.
| # | Points | Constraints |
|---|---|---|
| 1 | 30 | |
| 2 | 70 | No further constraints. |