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 ...
随机推荐
- 目前所有的ANN神经网络算法大全
http://blog.sina.com.cn/s/blog_98238f850102w7ik.html 目前所有的ANN神经网络算法大全 (2016-01-20 10:34:17) 转载▼ 标签: ...
- sublime text 主题推荐
Soda Spacegray Flatland Tomorrow Base 16 Solarized Predawn itg.flat 其他所有的配色方案和主题.
- arrayList LinkedList HashMap HashTable的区别
ArrayList 采用的是数组形式来保存对象的,这种方式将对象放在连续的位置中,所以最大的缺点就是插入删除时非常麻烦 LinkedList 采用的将对象存放在独立的空间中,而且在每个空间中还保存下一 ...
- 使用node-livereload自动刷新页面
1. 安装node 2. 安装python 3. 安装connect, serve-static和node-livereload (以下都假设命令行当前目录为e:\WebSite) e:\WebSit ...
- spring MVC 初探 (HelloWorld)
1.使用spring MVC 需要导入相关jar包 2.web.xml 启用spring MVC <servlet> <servlet-name>spring3mvc</ ...
- CentOS 6.5 GIT 服务器搭建
环境: Git Sserver IP: 10.6.0.2 Git Client IP: 10.6.0.126 1. 在 Git Server 安装软件所需的依赖包 yum install curl-d ...
- nginx keepalived 主从切换
注: LVS + Keepalived 不知道为什么出现一个很郁闷的问题....... ------------------------------------------------------ ...
- 跳舞链 Dancing Links
作为搜索里面的一个大头,终于刷了一部分题目了,跳舞链一般都有现成的模板来套...... 至于跳舞链的学习的话,我觉得http://www.cnblogs.com/grenet/p/3163550.ht ...
- iOS开发者需要的5款排版工具
Attributed String Creator Attributed String Creator可以从你的格式化文本中自动生成原生的Objective-C代码.你可以将文本写入.粘贴或者导入At ...
- mysql管理----状态参数释义
下面是数据库MySQL优化的一些步骤 一.通过show status和应用特点了解各种SQL的执行频率 通过SHOW STATUS可以提供服务器状态信息,也可以使用mysqladmin extende ...