Filling Shapes
Time limit1sMemory limit1024 MB
Count the ways to fill a 3 by n grid of tiles with the shape from the picture, with no gaps and no overlaps, for n up to 60.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
You have a given integer . Find the number of ways to fill all tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.

This picture describes when . The left one is the shape and the right one is tiles.
Input
The only line contains one integer (), the length.
Output
Print the number of ways to fill.
Hint
In the first example, there are possible cases of filling.
In the second example, you cannot fill the shapes in tiles.