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 ...
随机推荐
- eclipse proxy
-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.ht ...
- PAT (Advanced Level) 1013. Battle Over Cities (25)
并查集判断连通性. #include<iostream> #include<cstring> #include<cmath> #include<algorit ...
- [转] Eclipse 使用 Link 方式进行插件的安装
下方来自 http://www.iteye.com/topic/1113353 Eclipse 的插件安装方法一般有以下几种(以安装 SVN 插件为例说明,Eclipse 版本为:3.7/Indigo ...
- myEclipse 8.5下SVN环境的搭建
myEclipse 8.5下SVN环境的搭建 在应用myEclips 8.5做项目时,svn会成为团队项目的一个非常好的工具,苦苦在网上寻求了一下午,终于整合好了这个环境,在这里简单介绍下,希望能为刚 ...
- 一个很好玩的命令:stty
stty命令修改终端命令行的相关设置.语法stty(选项)(参数)选项-a:以容易阅读的方式打印当前的所有配置:-g:以stty可读方式打印当前的所有配置.参数终端设置:指定终端命令行的设置选项.实例 ...
- H3C inode for OSX 10.10 校园网客户端亲测可用
1.打开终端 2.输入以下命令 sudo /library/StartupItems/iNodeAuthService/iNodeAuthService start 3.输入管理密码 4.打开客户端联 ...
- OC语言的特性(一)-消息传递与调用函数的表现形式
我们在初学Objective-C时,都会觉得ObjC中的消息传递和其他语言的调用函数差不多,只是在OC中,方法调用用消息传递这一概念来代替. 那么到底怎样区别OC中的消息传递与其他语言的调用函数呢. ...
- iOS HTTP不能正常使用
- python mysql 2014 Commands out of sync; you can't run this command now
这个问题出现再 mysql和c 的api. 简单的解决方法是不使用api直接把整个连接和命令传过去. 例如,cmd = 'mysql -h 192.168.32.210 -P 3316 -u bfd ...
- IFrame跨域访问自定义高度
由于JS禁止跨域访问,如何实现不同域的子页面将高度返回给父页面本身,是解决自定义高度的难点. JS跨域访问问题描述:应用A访问应用B的资源,由于A,B应用分别部署在不同应用服务器(tomcat)上,属 ...