#P2080. ACSL 2021-2022 Senior Division Contest #1 Fibonacci Clock

ACSL 2021-2022 Senior 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:mm:sshh:mm:ss format. The colors will be given to you as a single string of 55 uppercase 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/.)

Each square has a color: red, green, blue, cyan, magenta, yellow, or white. All red squares represent only the number of hours; green squares represent only minutes; and blue squares represent only seconds. However, intersecting regions (in the Venn Diagram shown) are used to represent 22 different values: yellow represents both hours and minutes; magenta represents both hours and seconds; and cyan represents both minutes and seconds. White squares are ignored.

For both minutes and seconds, the sum of the values of the lengths is multiplied 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 or seconds is 6060 or more and/or if the number of hours is 1212 or more, change it to a valid time from 00:00:0000:00:00 to 11:56:5511:56:55. For example, 09:60:0009:60:00 would become 10:00:0010:00:00 and 12:00:6012:00:60 would be 00:01:0000:01:00.

In this modified version of the clock, the time displayed on the clock in the picture above is 01:15:3501:15:35. The hours are represented by the red 11 x 11 square. The minutes are represented by the green 33 x 33 square (35=15)(3 * 5 = 15), and the seconds are represented by the blue 22 x 22 and the blue 55 x 55 squares (2+5=7(2 + 5 = 7 and 75=35)7 * 5 = 35).

For example, the 22 illustrations below represent the first two sample inputs. The string “RWGBG” represents 11 hour, (2+5)5=35(2 + 5) * 5 = 35 minutes, and 35=153 * 5 = 15 seconds. The string “RCMGB’ represents 33 hours (1+2)(1 + 2), 2020 minutes ((1+3)5)((1 + 3) * 5), and 4040 seconds ((5+1+2)5)((5 + 1 + 2) * 5) or 03:20:4003:20:40.

INPUT FORMAT

There are 55 sets of data. Each set has a single 55-character string of 77 possible uppercase characters, such as “RWGBG”. The possible letters are R, G, B, C, M, Y, and W. The order is the lower 11 x 11, the upper 11 x 11, the 22 x 22, the 33 x 33, and the 55 × 55 square. We guarantee that the input will represent a valid time from 00:00:0000:00:00 to 11:56:5511:56:55.

OUTPUT FORMAT

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

SAMPLE

INPUT

RWGBG
RCMGB
BYYGR
MRGBW
YYYYY

OUTPUT

01:35:15
03:20:40
08:30:05
02:10:20
01:00:00