#P16489. [GKS 2014 #C] Tetris

    ID: 16474 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>模拟2014Google Kick Start

[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 WW by HH 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 77 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 rr. rr can be 00, 11, 22 or 33. 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 xx. It is the coordinate of the lower left square of a tetromino's bounding box. Here xx starts from 00.

The first line of the input gives the number of test cases, TT. For each test case, the first line of input has 33 integers, WW, HH, NN. WW is the width, HH is the height and NN is the number of blocks that are going to fall.

Then NN lines below, each line has 33 integers, tit_i, rir_i, xix_i. tit_i tells the tetromino type. rir_i is the rotation of this tetromino. xix_i is the horizontal falling position of this tetromino. It is guaranteed that xix_i 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 11). And then, if the game ends before the NN blocks, output "Game Over!"(without quotes). Otherwise, output the game field's final state, which should have HH lines, each has WW 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

1T1001 \le T \le 100

1ti71 \le t_i \le 7

0ri<40 \le r_i < 4

Small dataset (Test Set 1 - Visible)

4W204 \le W \le 20

1H201 \le H \le 20

0N1000 \le N \le 100

Large dataset (Test Set 2 - Hidden)

4W1004 \le W \le 100

1H1001 \le H \le 100

0N50000 \le N \le 5000