| Winter Cup 5.0 Online Mirror Contest |
|---|
| Finished |
In the world of Westeros, the Kingdoms of Westeros were constantly vying for power and control, each represented by a different color on the banners that flew high above their castles. But when a strange and powerful enemy threatened to destroy them all, the lords and ladies of the kingdoms realized that they needed to work together if they were to survive.
To do so, they turned to an ancient and mysterious mage, known by the name IronByte, who was said to have the power to solve any problem. The mage presented them with a strange riddle, stating that they needed to choose the colors of their banners in such a way that there were no adjacent banners with the same colours, or face the consequences.
The problem with that, is that many kingdoms have already installed their banners, and they cannot be altered. The only solution is to set the colours of the banners for the remaining kingdoms so that there will not be a pair of adjacent kingdoms with the same colour.
Now, the banners are represented by a string $$$S$$$ where $$$S_i$$$ is:
A final critical problem, is the budget Kingdoms is limited, so they should use as few colours as possible.
Please help them to determine the minimal number of colours they need to solve the riddle, or $$$-1$$$ if they will face imminent destruction.
A single integer $$$n$$$ representing the minimal number of colours, or $$$-1$$$ if it is impossible to have adjacent pairs with different colours.
5 RG..R
2
5 RG.BG
3
| Name |
|---|


