当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3476:A Game with Colored Balls

题目描述

Given a chain of N (1 ≤ N ≤ 106) balls colored either red (‘R’), green (‘G’) or blue (‘B’) and numbered sequentially 1 through N from left to right, a game proceeds as follows:

  1. Pick the leftmost segment containing the largest number of consecutive balls of the same color.
  2. 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.
  3. Report the color and numbers of the removed balls.
  4. Go back to step 1 if any balls remain.

Write a program to simulate the process of a game.

输入解释

The input contains only a string of ‘R’s, ‘G’s and ‘B’s representing the balls in the chain from left to right.

输出解释

For each segment dislodged, output whatever is reported following the sample output’s example.

输入样例
GRRBBBRRGB
输出样例
B 4 5 6
R 2 3 7 8
G 1 9
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 2500MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3476

最后修改于 2020-10-29T07:02:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000 131072