301811: CF342D. Xenia and Dominoes

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Xenia and Dominoes

题意翻译

### 题意 在一个 $3*n$ 的桌子上放一些 $1*2$ 的多米诺骨牌(横竖放都可以),桌子上有一些`不能放置的格子`,除此以外,还要求一个指定的`空位`不能被多米诺骨牌覆盖,同时这个空位可以通过移动附近的骨牌来转移到其他地方,剩下的格子要被全部覆盖,求放置的种数。 ### 输入格式 第一行一个数 $n$。 接下来 $n$ 行描述整张桌子,"$O$" 表示`空位`,"$X$" 表示`不能放置的格子`。 ### 输出格式 第一行一个数,问题的答案模 $1e9+7$。 ### 数据范围 $3\leq n\leq 10^4$

题目描述

Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF342D/2b683a77cca9d644b43e409b02fa4a6043e6f755.png)A puzzle is a $ 3×n $ table with forbidden cells (black squares) containing dominoes (colored rectangles on the picture). A puzzle is called correct if it meets the following conditions: - each domino occupies exactly two non-forbidden cells of the table; - no two dominoes occupy the same table cell; - exactly one non-forbidden cell of the table is unoccupied by any domino (it is marked by a circle in the picture). To solve the puzzle, you need multiple steps to transport an empty cell from the starting position to some specified position. A move is transporting a domino to the empty cell, provided that the puzzle stays correct. The horizontal dominoes can be moved only horizontally, and vertical dominoes can be moved only vertically. You can't rotate dominoes. The picture shows a probable move. Xenia has a $ 3×n $ table with forbidden cells and a cell marked with a circle. Also, Xenia has very many identical dominoes. Now Xenia is wondering, how many distinct correct puzzles she can make if she puts dominoes on the existing table. Also, Xenia wants the circle-marked cell to be empty in the resulting puzzle. The puzzle must contain at least one move. Help Xenia, count the described number of puzzles. As the described number can be rather large, print the remainder after dividing it by $ 1000000007 $ $ (10^{9}+7) $ .

输入输出格式

输入格式


The first line contains integer $ n $ $ (3<=n<=10^{4}) $ — the puzzle's size. Each of the following three lines contains $ n $ characters — the description of the table. The $ j $ -th character of the $ i $ -th line equals "X" if the corresponding cell is forbidden; it equals ".", if the corresponding cell is non-forbidden and "O", if the corresponding cell is marked with a circle. It is guaranteed that exactly one cell in the table is marked with a circle. It is guaranteed that all cells of a given table having at least one common point with the marked cell is non-forbidden.

输出格式


Print a single number — the answer to the problem modulo $ 1000000007 $ $ (10^{9}+7) $ .

输入输出样例

输入样例 #1

5
....X
.O...
...X.

输出样例 #1

1

输入样例 #2

5
.....
.O...
.....

输出样例 #2

2

输入样例 #3

3
...
...
..O

输出样例 #3

4

说明

Two puzzles are considered distinct if there is a pair of cells that contain one domino in one puzzle and do not contain it in the other one.

Input

题意翻译

### 题意 在一个 $3*n$ 的桌子上放一些 $1*2$ 的多米诺骨牌(横竖放都可以),桌子上有一些`不能放置的格子`,除此以外,还要求一个指定的`空位`不能被多米诺骨牌覆盖,同时这个空位可以通过移动附近的骨牌来转移到其他地方,剩下的格子要被全部覆盖,求放置的种数。 ### 输入格式 第一行一个数 $n$。 接下来 $n$ 行描述整张桌子,"$O$" 表示`空位`,"$X$" 表示`不能放置的格子`。 ### 输出格式 第一行一个数,问题的答案模 $1e9+7$。 ### 数据范围 $3\leq n\leq 10^4$

加入题单

上一题 下一题 算法标签: