B. Blown Garland
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

 #include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
char str[];
int main()
{
while(~scanf("%s",str))
{
int r, b, y, g;
int ans[] = {};
for(int i = ; str[i]; i++)
{
if(str[i] == 'R')
r = i%;
else if(str[i] == 'B')
b = i%;
else if(str[i] == 'Y')
y = i%;
else if(str[i] == 'G')
g = i%;
else
ans[i%]++;
}
printf("%d %d %d %d\n",ans[r],ans[b],ans[y],ans[g]);
//cout << r << " " << b << " " << y << " " << g << endl;
}
return ;
}

758B Blown Garland的更多相关文章

  1. Codeforces 758B Blown Garland

    题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就 ...

  2. 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 ...

  3. 【codeforces 758B】Blown Garland

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. Codeforces 758B:Blown Garland(模拟)

    http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的 ...

  5. B. Blown Garland

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  6. Codeforces 392 B Blown Garland

    题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯.简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然 ...

  7. Codeforces758B

    B. Blown Garland time limit per test:1 second memory limit per test:256 megabytes input:standard inp ...

  8. Codeforces Round #392 (Div. 2) A B C 水 模拟 暴力

    A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. POJ 1759 Garland(二分+数学递归+坑精度)

    POJ 1759 Garland  这个题wa了27次,忘了用一个数来储存f[n-1],每次由于二分都会改变f[n-1]的值,得到的有的值不精确,直接输出f[n-1]肯定有问题. 这个题用c++交可以 ...

随机推荐

  1. 吴裕雄 25-MySQL 临时表

    MySQL 临时表MySQL 临时表在我们需要保存一些临时数据时是非常有用的.临时表只在当前连接可见,当关闭连接时,Mysql会自动删除表并释放所有空间.临时表在MySQL 3.23版本中添加,如果你 ...

  2. 吴裕雄 21-MySQL 正则表达式

    MySQL 正则表达式在前面的章节我们已经了解到MySQL可以通过 LIKE ...% 来进行模糊匹配.MySQL 同样也支持其他正则表达式的匹配, MySQL中使用 REGEXP 操作符来进行正则表 ...

  3. 零基础用Docker部署微服务

    1. docker架构 这里的Client和DOCKER_HOST(docker server)都是在本地的,docker仓库Registry是在远程的: Client的docker命令通过Docke ...

  4. 三种方法让Response.Redirect在新窗口打开

    通过设置form的target属性同样可以让Response.Rederect所指向的url在新的窗口打开,下面为大家介绍三种具体的实现方法 Response.Rederect在默认情况下是在本页跳转 ...

  5. Kafka日志及Topic数据清理

    由于项目原因,最近经常碰到Kafka消息队列拥堵的情况.碰到这种情况为了不影响在线系统的正常使用,需要大家手动的清理Kafka Log.但是清理Kafka Log又不能单纯的去删除中间环节产生的日志, ...

  6. 环境变量之path的一点理解

    最初安装java环境时一直不明白为什么要配置环境变量,百度了一下还是理解不透彻. 后来安装python时也要配置环境变量.. 在经过未配置和配置的操作后,才有些理解path的含义. 1.未配置环境变量 ...

  7. CKfinder for java详解二:缩略图及图片上传的缩放

    我们找到 <thumbs><enabled>true</enabled><url>�SE_URL%_thumbs/</url><dir ...

  8. 虚拟机 安装 CentOS7

    初次接触CentOS,最好是在虚拟机中安装: 因为CentOS的安装选项有很多,不理解的情况下千万不要在物理机上尝试: 不然可能出现这种情况:安装好以后,只有黑色的屏幕,只能在里面敲命令:这对于新手来 ...

  9. 基于正则表达式用requests下载网页中的图片

    在慕课网看了正则表达式和requests的课程后,为了加深学习记忆,决定简单记录. 实现步骤: 1.先打开你要下载的网页,查看源码找出图片位置 2.编写正则匹配图片url 3.保存图片到本地 图文步骤 ...

  10. Mybatis学习链接

    mybatis实战教程(mybatis in action),mybatis入门到精通   http://blog.csdn.net/techbirds_bao/article/details/923 ...