DWITE '07 R5 #5 - Tetris!

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, February 2008, Problem 5

You are working on a part of Tetris! playing AI that figures out the best move for the current piece, and one part of the information required for this decision is knowing the maximum number of lines that the current piece can score on a given board.

The board size is 10 units in width, and 6 in height. A line is complete when all 10 units across are filled with a game piece. It is made up of 2 possible characters:

  • # - piece on a board
  • . - empty spot

Pieces in play are standard Tetris pieces, and the current game piece will be described in a 4 by 4 matrix, at the beginning of each data set. The pieces can rotate, and thus can be presented in any orientation. Same character map as the board applies. For example:

....
.##.
##..
....

The input will come in 5 sets, repeating the following pattern: 4 lines, 4 characters each, describing the current piece in play. Followed by 6 lines, 10 characters each, describing the current board.

The output will contain 5 lines – a maximum number of lines that a piece can score.

Note: The piece starts dropping from above the supplied 6 \times 10 board, and cannot be moved sideways during the fall. That is, you need to concern yourself only with the vertical drop.

Sample Input

....
.#..
.###
....
..........
..........
..........
#####..###
##.##.####
#####.####

Sample Output

2

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments


  • -1
    chengli20174  commented on June 25, 2019, 8:15 p.m.

    What does it mean by, "cannot be moved sideways"? The only way to get two lines is to rotate the piece.


    • 0
      YouKnowMe  commented on April 11, 2022, 2:28 p.m.

      its so that once you "drop the pice" that is its commitment. you cannot change is trajectory and squeeze it into other spots