Codeforces758B
B. Blown Garland
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.
Input
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.
Output
In the only line print four integers kr, kb, ky, kg — the number of dead light bulbs of red, blue, yellow and green colors accordingly.
Examples
input
RYBGRYBGR
output
0 0 0 0
input
!RGYB
output
0 1 0 0
input
!!!!YGRB
output
1 1 1 1
input
!GB!RG!Y!
output
2 1 1 0
Note
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.
//2017.01.19
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
string light;
int k[];
char l[] = {'r', 'b', 'y', 'g'};
int order[];
while(cin >> light)
{
int cnt = ;
memset(order, , sizeof(order));
memset(k, , sizeof(k));
for(int i = ; i < light.length(); i++)
{
if(light[i] != '!')
{
if(light[i] == 'R')order[i%] = ;
else if(light[i] == 'B')order[i%] = ;
else if(light[i] == 'Y')order[i%] = ;
else if(light[i] == 'G')order[i%] = ;
}
}
for(int i = ; i < light.length(); i++)
{
if(light[i] == '!')
k[order[i%]]++;
}
for(int i = ; i <= ; i++)
if(i == )cout<<k[i]<<endl;
else cout<<k[i]<<" ";
} return ;
}
Codeforces758B的更多相关文章
- Codeforces758B Blown Garland 2017-01-20 10:19 87人阅读 评论(0) 收藏
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
随机推荐
- phpcms 细节
Phpcms V9采用if语句判断当前栏目高亮.判断分类信息是否过期 10月05, 2013 by SJY 在用PC V9建站的时候,很多朋友会想到Phpcms V9判定当前栏目,让当前栏目高亮的功能 ...
- flex中form表单中子元素之间的距离控制
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.ado ...
- webapp之路--之query media
query media是css3中的模块,对于移动端的开发是非常重要的,是响应式web设计的中不可或缺的一部分.简单点说就是根据不同移动设备的屏幕参数来制定不同的css方案以实现web的响应式开发.目 ...
- ActiveMQ讯息传送机制以及ACK机制
http://blog.csdn.net/lulongzhou_llz/article/details/42270113 ActiveMQ消息传送机制以及ACK机制详解 AcitveMQ是作为一种消息 ...
- sort用法
一.sort用法sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次按ASCII码值进行比较,最后将他们按升序输出.vim 1.txt 1:datadir=/aaa/zzz:2: ...
- fedora 挂载 小米手机 (估计其它android设备也是类似操作)
1 参考ubuntu挂载 在Ubuntu挂载使用MTP设备步骤如下: 1.将MTP设备连接至PC机 2.如果是第一次使用MTP设备需要安装以下软件,否则可以跳过此步骤: $ sudo apt-get ...
- ARM-LINUX学习笔记-1
安装完linux之后记得系统更新,更新使用apt命令,如下(记得使用之前使用sudo -i 指令切换到root用户模式) apt-get update 更新系统软件源,相当于查找更新 apt-get ...
- IdTCP的C++Builder2010示例(转)
源:IdTCP的C++Builder2010示例 IdTCP的C++Builder2010示例 这个是服务端的: void __fastcall TTCPDataServer::TCPServerEx ...
- IOS开发-ObjC-Category的使用
在IOS移动App开发中,经常会出现以下情况:定义好了一个类,但后来需求升级或改变之后需要对这个类增加功能,这样的话往往需要修改类的结构,这样就会导致不能预期的问题产生,所以Obj-C提供了一种叫做C ...
- problem 202,263、232、21、231
[263]Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are ...