#P2076. ACSL 2021-2022 Intermediate Division Contest #1 Fibonacci Clock

ACSL 2021-2022 Intermediate Division Contest #1 Fibonacci Clock

ACSL’s version of Philippe Chretien’s “Fibonacci Clock” displays time by changing the colors displayed in 55 squares, whose side lengths correspond to the first 55 Fibonacci numbers (1,1,2,3,1, 1, 2, 3, and 55). Given the colors of the squares on the clock face, you must output the time that is represented in hh:mmhh:mm format. The colors will be given to you as 55 individual characters representing the lower 11 x 11 square, the upper 11 x 11 square, the 22 x 22 square, the 33 x 33 square, and the 55 x 55 square in that order. (See https://basbrun.com/2015/05/04/fibonacci-clock/.)

Red squares are used to represent only hours and green squares are used to represent only minutes. Blue squares are used to represent both hours and minutes. White squares are ignored. To find the current hour, add the values of the red and blue squares. To find the current minutes, add the values of the green and blue squares and multiply by 55 so that the number of minutes and seconds are in intervals of 55 between 00 and 6060 inclusive.

However, if the number of minutes is 6060, change it to the next hour with 00 minutes and if the number of hours is 1212 or more, change it to a valid time from 00:0000:00 to 11:5511:55. For example, 09:6009:60 would become 10:0010:00 and 12:6012:60 would be 01:0001:00.

The clock in the picture above is displaying 08:5008:50. The hours are represented by the red 11 x 11, blue 22 x 22, and blue 55 x 55 squares (1+2+5=8)(1 + 2 + 5 = 8). The minutes are represented by the blue 22 x 22, the green 33 x 33, and the blue 55 x 55 squares (2+3+5=10,(2+3+5=10, and 105=50)10*5=50).

The example at the left which uses the inputted characters R, W, G, B, G displays the time 04:5004:50. The hours are represented by the 11 x 11 red square and the 33 x 33 blue square: 1+3=41 + 3 = 4. The minutes are represented by the 22 x 22 green, the 33 x 33 blue, and the 55 x 55 green squares: (2+3+5)5=50(2 + 3 + 5) * 5 = 50. The example at the right which uses the inputted characters W, B, B, G, R displays the time 08:3008:30. The hours are 1+2+5=81 + 2 + 5 = 8 and the minutes are (1+2+3)5=30(1 + 2 + 3) * 5 = 30.

INPUT FORMAT

There are 55 sets of data. Each set has 55 uppercase letters (R, W, B, or G) that represent the colors of the lower 11 x 11, the upper 11 x 11, the 22 x 22, the 33 x 33, and finally the 55 x 55 square, in that order. We guarantee that the input will represent a valid time from 00:0000:00 to 11:5511:55.

OUTPUT FORMAT

For each line of data, print the time in hours and minutes formatted as hh:mmhh:mm.

SAMPLE

INPUT

R W G B G
W B B G R
W G B R B
G G B B B
W R G G G

OUTPUT

04:50
08:30
10:40
11:00
01:50