#P6762. [BalticOI 2010] Lego (Day1)
[BalticOI 2010] Lego (Day1)
Description
You are given some LEGO blocks, each of which is colored white (W), gray (G), or black (B). You need to place the blocks onto a baseboard. The placement must not go outside the baseboard, and there must not be any completely floating block (i.e., the four unit squares of that block all have nothing underneath to support them).
Now you are given a sketch of one side of the baseboard after all blocks have been placed, and a sketch of the side obtained by rotating this side counterclockwise by . Compute how many different ways there are to place the blocks.
Input Format
The first line contains an integer , representing the height of the construction.
The next lines each contain six characters, describing the sketch as seen from this side.
The next lines each contain six characters, describing the sketch as seen from the side obtained by rotating the previous side counterclockwise by .
You can only view from the front, back, left, and right sides, and you cannot view from the top or bottom.
Output Format
Output one integer, representing the answer.
The answer is guaranteed to fit in a 64-bit signed integer.
2
WWGG..
.BB.WW
.WGG..
WWGG..
6
Hint
Explanation for Sample 1
As shown in the figure:

The first one is the sketch observed from side .
The second one is the sketch observed from side (side rotated counterclockwise by ).
Below are these cases (thanks to Vonov for the pictures!):






Constraints
For of the testdata, .
Note
Translated from BalticOI 2010 Day1 B Lego。
Translated by ChatGPT 5
京公网安备 11011102002149号