Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: A Game with Colored Balls
Description Given a chain of - Pick the leftmost segment containing the largest number of consecutive balls of the same color.
- If the segment contains only one ball, the game ends; otherwise dislodge it from the chain. If the remaining balls are broken into two chains, join them maintaining their order.
- Report the color and numbers of the removed balls.
- Go back to step 1 if any balls remain.
Write a program to simulate the process of a game. Input The input contains only a string of ‘ Output For each segment dislodged, output whatever is reported following the sample output’s example. Sample Input GRRBBBRRGB Sample Output B 4 5 6 R 2 3 7 8 G 1 9 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator