CF758B.Blown Garland
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is working.
It is known that the garland contains light bulbs of four colors: red, blue, yellow and green. The garland is made as follows: if you take any four consecutive light bulbs then there will not be light bulbs with the same color among them. For example, the garland can look like "RYBGRYBGRY", "YBGRYBGRYBG", "BGRYB", but can not look like "BGRYG", "YBGRYBYGR" or "BGYBGY". Letters denote colors: 'R' — red, 'B' — blue, 'Y' — yellow, 'G' — green.
Using the information that for each color at least one light bulb still works count the number of dead light bulbs of each four colors.
世间万物皆非永恒,科斯佳在1月7日看到一串部分损坏的四色彩灯时,深刻理解了这一点。
现在他的目标是更换所有损坏的灯泡,但他并不知道每种颜色各需多少个新灯泡。题目保证:四种颜色中,每种颜色至少有一个灯泡仍在正常工作。
已知该彩灯由四种颜色的灯泡组成:红色(R)、蓝色(B)、黄色(Y)和绿色(G)。其排列规则如下:任意连续四个灯泡中,不会出现相同颜色的灯泡。例如,以下字符串是合法的彩灯序列:“RYBGRYBGRY”、“YBGRYBGRYBG”、“BGRYB”;而以下字符串则不合法:“BGRYG”、“YBGRYBYGR”或“BGYBGY”。其中字母代表颜色:'R' 表示红色,'B' 表示蓝色,'Y' 表示黄色,'G' 表示绿色。
利用“每种颜色至少有一个灯泡仍在正常工作”这一信息,请计算出每种颜色各自损坏的灯泡数量。
输入格式
The first and the only line contains the string s (4 ≤ |s| ≤ 100), which describes the garland, the i-th symbol of which describes the color of the i-th light bulb in the order from the beginning of garland:
- 'R' — the light bulb is red,
- 'B' — the light bulb is blue,
- 'Y' — the light bulb is yellow,
- 'G' — the light bulb is green,
- '!' — the light bulb is dead.
The string s can not contain other symbols except those five which were described.
It is guaranteed that in the given string at least once there is each of four letters 'R', 'B', 'Y' and 'G'.
It is guaranteed that the string s is correct garland with some blown light bulbs, it means that for example the line "GRBY!!!B" can not be in the input data.
第一行且唯一一行包含字符串 s(4 ≤ ∣s∣ ≤ 100),用于描述彩灯串,其中第 i 个字符表示从彩灯串开头起第 i 个灯泡的颜色:
'R'— 灯泡为红色,'B'— 灯泡为蓝色,'Y'— 灯泡为黄色,'G'— 灯泡为绿色,'!'— 灯泡已损坏。
字符串 s 中仅可包含上述五种字符,不能包含其他任何字符。
保证在给定的字符串中,四个字母 'R'、'B'、'Y' 和 'G' 至少各出现一次。
保证字符串 s 是一个合法的彩灯串(其中部分灯泡已损坏),即例如 "GRBY!!!B" 这样的字符串不可能出现在输入数据中。
输出格式
In the only line print four integers k__r, k__b, k__y, k__g — the number of dead light bulbs of red, blue, yellow and green colors accordingly.
在唯一的一行中输出四个整数 kr, kb, ky, kg —— 分别表示红色、蓝色、黄色和绿色坏掉的灯泡数量。
输入输出样例
输入#1
RYBGRYBGR
输出#1
0 0 0 0
输入#2
!RGYB
输出#2
0 1 0 0
输入#3
!!!!YGRB
输出#3
1 1 1 1
输入#4
!GB!RG!Y!
输出#4
2 1 1 0
说明/提示
In the first example there are no dead light bulbs.
In the second example it is obvious that one blue bulb is blown, because it could not be light bulbs of other colors on its place according to the statements.
在第一个例子中,没有坏掉的灯泡。
在第二个例子中,显然有一个蓝色灯泡烧坏了,因为根据题设条件,该位置不可能是其他颜色的灯泡。
输入解题思路,AI测评打分。不知道怎么写?