DominoesFalling
TCCC06 Sponsor 2 · 2006-08-22 · by Andrew_Lazarev
Problem Statement
This problem contains an image that can be viewed in the applet.
The domino effect is a chain reaction triggered by a single tile falling down. The tile falls into another tile, which falls into the next tile, and so on (see picture below).

Consider an infinite line of cells, some of which are occupied by tiles. We want to arrange the tiles in such a way that pushing the leftmost tile will lead to all the tiles falling down. A tile will push down a neighboring tile to its right if there are between 1 and 4 free cells, inclusive, between them.
You will be given a
Constraints
- cells will contain between 1 and 50 elements, inclusive.
- Each element of cells will contain between 1 and 50 characters, inclusive.
- Each element of cells will contain only '.' and uppercase 'X' characters.
- cells will contain at least two 'X' characters.
{"XX"}
Returns: 1
The tiles are too close. So, we need to move one them.
{"X.....X"}
Returns: 1
The tiles are too far apart. So, we need to move one them.
{"X.X............",
"...............",
".....X.X.X.....",
"...............",
"............X.X"}
Returns: 4
{"X.X....X..X...", ".X......"}
Returns: 0
{".XX.X.XXXXXX", "X.X.XXXXXXXXXXXX", ".X.X.X.XXXXXXX.XXX", ".XXXXXX.XX",
"XX.XXXXX.XXXXX", "XXXXX...X...X", "XXXX.XXXXXXXXX.XXXXX"}
Returns: 34
Submissions are judged against all 67 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DominoesFalling with a public method int rearrangeTiles(vector<string> cells) · 67 test cases · 2 s / 256 MB per case