DrawingBlackCrosses
SRM 466 · 2009-11-12 · by Chmel_Tolstiy
Problem Statement
Each solution to this puzzle can be written as a sequence of cells, where the i-th cell in the sequence is the cell that was selected on the player's i-th move. Two solutions are considered to be different if these sequences have different lengths or if there's an index i such that the i-th cells in these sequences are different. You are given a
Constraints
- field will contain between 1 and 20 elements, inclusive.
- Each element of field will contain between 1 and 20 characters, inclusive.
- All elements of field will have the same length.
- Each character in field will be either 'B' or '.'.
- field will contain no more than 8 'B' characters.
Statement by TopCoder, Inc. — view the original on the archive.
{"."}
Returns: 1
Only one possible move.
{"BBB",
"BBB"}
Returns: 1
No moves are necessary here since all the cells are already black.
{"...",
"BB."}
Returns: 5
Let's number rows and columns of the grid as follows: 012 0 ... 1 BB. The following sequences of moves are possible (the first coordinate of each cell is its row number, the second coordinate is column number): 1. (0, 0), (1, 2); 2. (0, 1), (1, 2); 3. (0, 2); 4. (1, 2), (0, 0); 5. (1, 2), (0, 1).
{"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"....................",
"...................."}
Returns: 563200757
{"B..B",
"B.B.",
"...B",
"BB.B",
"...."}
Returns: 324
Submissions are judged against all 178 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DrawingBlackCrosses with a public method int count(vector<string> field) · 178 test cases · 2 s / 256 MB per case