JOI Spring Training Camp 2015/16
Original Statement / Submission Site
JOI is playing a game using a grid board that is 3 cells tall and N cells wide, along with several tokens. In the initial state of the game, some cells contain a token, and some cells do not.
The goal of the game is to place a token on each empty cell, one at a time, until all cells on the board contain a token. However, a token can only be placed on a cell if at least one of the following conditions is satisfied:
JOI is curious to know how many different sequences of token placements can lead from the initial state to the final state where all cells are filled.
Note that the number of possible sequences can be very large, so your task is to compute the number of valid sequences modulo 1,000,000,007.
Given the initial state of the game, write a program to compute the number of valid sequences to complete the board, modulo 1,000,000,007.
Print a single line containing the number of valid sequences modulo 1,000,000,007.
1 ≤ N ≤ 2,000
3 oxo xxo oxo
14
The initial board state is:
o x o x x o o x o
There are 14 valid sequences to place the tokens and complete the board. The sequences of placements are illustrated below (numbers indicate order of placement):
o 1 o o 1 o o 1 o o 1 o o 2 o o 2 o o 3 o o 4 o o 3 o o 4 o o 2 o o 2 o o 3 o o 4 o 2 3 o 2 4 o 3 4 o 4 3 o 1 3 o 1 4 o 1 2 o 1 2 o 1 4 o 1 3 o 3 4 o 4 3 o 2 4 o 2 3 o o 4 o o 3 o o 2 o o 2 o o 4 o o 3 o o 4 o o 3 o o 2 o o 2 o o 1 o o 1 o o 1 o o 1 o
10 ooxooxoxoo xooxxxoxxx oxoxoooooo
149022720
10 ooxoxxoxoo oxxxxxoxxx oxooxoxoxo
0
In this case, it is impossible to fill all cells.
20 oxooxoxooxoxooxoxoxo oxxxoxoxxxooxxxxxoox oxooxoxooxooxooxoxoo
228518545