Tetris
Time limit2sMemory limit128 MB
Count the number of ways to tile a 3xN grid using square, T, S, Z, L, and J tetrominoes (no straight piece), modulo 1,000,000.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Matrix
- Solved
- No attempts yet
Problem
You want to fill a rectangle completely with Tetris pieces.
The available pieces are the six tetrominoes shaped like a square, T, S, Z, L, and J. You may use each piece as many times as needed, and each piece may be rotated by , , or . The straight tetromino is not used.
Pieces must be placed on the grid, must not overlap, and must not extend outside the rectangle. Count the number of possible tilings.
Input
The first line contains a positive integer . is at most .
Output
Print the number of ways to fill the rectangle with the pieces, modulo .