#P16489. [GKS 2014 #C] Tetris
[GKS 2014 #C] Tetris
题目描述
Tetris is a famous video game that almost everyone has played it. In this problem, you need to simulate a simplified version of it.
In our version, the game is played in a by field with gravity. At the beginning, the field is empty. Then the tetrominos start to fall from above top of the field to bottom of the field, one by one. Each tetromino will stop as soon as it touches some other tetrominos or bottom of the field.
One interesting feature of the game is called "line clearing". A line will be cleared as soon as it is filled by tetrominos. More than one line may be cleared at a time. For example:
|..............| |..............| |..............|
|.............o| |..............| |..............|
|.............o| |..............| |..............|
|.............o| |..............| |..............|
|.............o| |..............| |..............|
|..xx..........| --> |..xx..........| --> |..............|
|xxxxxxxxxxxxx.| |xxxxxxxxxxxxxo| |..............|
|xxxxxxxxxxxxx.| |xxxxxxxxxxxxxo| |..xx..........|
|xx..xxxxxxxxx.| |xx..xxxxxxxxxo| |xx..xxxxxxxxxo|
|xxxxxxxxxxx...| |xxxxxxxxxxx..o| |xxxxxxxxxxx..o|
---------------- ---------------- ----------------
Falling Stopped Cleared 2 lines
Note that in this simplified version, the "floating" tetromino blocks won't continue to fall after lines are cleared. This is why the top-most two squares will keep in such position. Consequently, cascade clearing won't happen, even though it would happen in the original version of Tetris.
The game ends when all the given tetrominos are placed, or the current tetromino cannot be placed due to the height limit of the field is reached.
In this problem, each tetromino will has its type, rotation and falling position told by the input. They will start to fall from the above of the field. Your goal is to simulate and get the final result of each play.
输入格式
We have types of tetromino:
1 2 3 4 5 6 7
x x x x xx x x
xx xx x x xx x xxx
x x xx xx x
x
Rotation of a tetromino is represented by a number . can be , , or . Rotation is counterclockwise. For example:
r=0 r=1 r=2 r=3
x x xxx x
xxx xx x xx
x x
x xx x xx
xx xx xx xx
x x
The horizontal falling position is represented by a number . It is the coordinate of the lower left square of a tetromino's bounding box. Here starts from .
The first line of the input gives the number of test cases, . For each test case, the first line of input has integers, , , . is the width, is the height and is the number of blocks that are going to fall.
Then lines below, each line has integers, , , . tells the tetromino type. is the rotation of this tetromino. is the horizontal falling position of this tetromino. It is guaranteed that will make the tetromino inside the field, horizontally.
输出格式
For each test case, first output one line containing "Case #i:", where i is the test case number (starting from ). And then, if the game ends before the blocks, output "Game Over!"(without quotes). Otherwise, output the game field's final state, which should have lines, each has characters. Each character can be '.' or 'x'.
5
8 6 1
1 0 0
5 4 1
1 1 1
5 6 3
5 0 0
5 0 2
3 2 3
6 4 3
6 2 0
6 2 0
6 2 0
6 4 2
6 0 0
6 0 1
Case #1:
........
........
........
x.......
xx......
.x......
Case #2:
.....
.....
..xx.
.xx..
Case #3:
.....
.....
.....
.....
.....
...xx
Case #4:
Game Over!
Case #5:
xx....
xx....
xx....
xx....
提示
Limits
Small dataset (Test Set 1 - Visible)
Large dataset (Test Set 2 - Hidden)