Get Time

   Problem Statement  

 Problem Statement for BlackBoxDiv2

Problem Statement

    Cat Upper has a rectangular black box. On the bottom of the box there is a grid that divides the box into identical square cells. There are no walls between the cells. The sides of the box are transparent, the top and bottom are opaque (i.e., Upper cannot see through them). Some of the cells are filled: each of them contains an opaque black block that fills the entire cell. The remaining cells are empty.

Cat Upper looked into the black box from the front and recorded what he saw: Whenever a column of the grid was completely empty, he could see through the box and wrote down '.' (a period). And whenever a column of the grid contained at least one block, Upper could not see through the box and he wrote down 'B'.

Then, he looked into the black box from the left side and again he recorded what he saw: for each row of the grid he wrote '.' if the row was completely empty and 'B' otherwise.

You are given the recorded information in two Strings: front and side.

Return the number of possible arrangements of the opaque blocks within the black box, modulo 1,000,000,007. Note that you don't know the exact number of blocks in the black box.


Parameters:String, String
Method signature:int count(String front, String side)
(be sure your method is public)


-front and side will each contain between 1 and 50 characters, inclusive.
-Each character in front and side will be 'B' or '.'.


Returns: 7
There are seven possible arrangements, as shown in the figure below.

Returns: 1
There is no block, thus there is exactly 1 valid arrangement: the one where all cells are empty.
Returns: 0
There is no possible arrangement. Upper must have made a mistake.
Returns: 16081
Returns: 771030153

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 602 Round 1 - Division II, Level Three