DOMINO1 - The Longest Chain of Domino Tiles
You are given N domino tiles. Each tile is made of some number of squares (not necessarily two), and each square is coloured either white or black (we use the Croatian letters: B for white and C for black).
Find the longest chain that can be made of these tiles. Each tile can be used at most once and cannot be rotated (for example, BC cannot become CB). The chain is made by a common rule: in adjacent tiles, touching squares must be of the same colour.
[N ≤ 100, the number of dominoes]
in the next N lines:
[a string of size between 1 and 100, representing the domino]
The length of the longest chain.
Input:4 CB BCC BBCC BCBBCOutput:11
Adrian Satja Kurdija:
Sorry. I forgot to enable all the test cases: only the first test case was tested. Now the brute force doesn't work.
will brute force work?