[Solution] Hot Black Hot White Codeforces Solution
One day, you are accepted as being Dr. Chanek's assistant. The first task given by Dr. Chanek to you is to take care and store his magical stones.
Dr. Chanek has magical stones with being an even number. Those magical stones are numbered from to . Magical stone has a strength of . A magical stone can be painted with two colours, namely the colour black or the colour white. You are tasked to paint the magical stones with the colour black or white and store the magical stones into a magic box with a magic coefficient (). The painting of the magical stones must be done in a way such that there are black magical stones and white magical stones.
Define for two integers and as the result of concatenating the digits of to the left of in their decimal representation without changing the order. As an example, will result in .
For a magic box with a magic coefficient , magical stone will react with magical stone if the colours of both stones are different and . A magical stone that is reacting will
be very hot and dangerous. Because of that, you must colour the magical stones and determine the magic coefficient of the magic box in a way such that there is no magical stone that reacts, or report if it is impossible.
The first line contains a single even integer () — the number of magical stones Dr. Chanek has.
The second line contains integer () — the strengths of all magical stones.
If it is not possible to satisfy the condition of the problem, output .
Otherwise, output two lines. The first line contains an integer denoting the magic coefficient of the magic box. The second line contains a string of length . is if magical stone is coloured black or if magical stone is coloured white. If there are more than one possibilities of colouring and choosing the magic coefficient , output any of them.
No comments:
Post a Comment