DominoTiling
SRM 722 · 2017-10-11 · by erinn
Problem Statement
You are given a
You want to cover all the '.' cells using a collection of disjoint 2x1 dominos. Return the number of ways to do this. Two ways are considered different if two cells are covered by the same domino in one tiling and by two different dominos in the other tiling.
Constraints
- grid will contain between 1 and 12 elements, inclusive.
- The length of each element of grid will be between 1 and 12, inclusive.
- Each element of grid will be the same length.
- Each character of each element of grid will be '.' or 'X'.
{"..",
".."}
Returns: 2
There are exactly two ways to do this: -- or || -- ||
{"...",
".X.",
"..."}
Returns: 2
Again, there are two solutions: --| |-- |X| |X| |-- --|
{"...",
"...",
"..X"}
Returns: 4
||| --| |-- --| ||| --| |-- ||| --X __X --X ||X
{".....",
".....",
".X...",
".X..."}
Returns: 29
{"..","..",".."}
Returns: 3
Submissions are judged against all 17 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DominoTiling with a public method long long count(vector<string> grid) · 17 test cases · 2 s / 256 MB per case