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.

 //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的更多相关文章

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

随机推荐

  1. php 自动发送邮件的实现

    原文: http://www.cnblogs.com/zichi/p/4058055.html http://www.jb51.net/article/32479.htm 效果: 访问: test.p ...

  2. PAT (Advanced Level) 1018. Public Bike Management (30)

    先找出可能在最短路上的边,图变成了一个DAG,然后在新图上DFS求答案就可以了. #include<iostream> #include<cstring> #include&l ...

  3. CodeForces 626C Block Towers

    构造AC的.左右两边都先不用6的倍数,然后哪边数字大那一边往回退一下,然后再比较哪边数字大.......直到结束 #include<cstdio> #include<cstring& ...

  4. redhat7 常用命令

    关闭防火墙 systemctl stop firewalld 查看防火墙状态 systemctl status firewalld 永久关闭防火墙命令.重启后,防火墙不会自动启动.systemctl ...

  5. 微信小程序下拉刷新和上拉加载

    小程序知识点二 1.上拉加载和下拉刷新 Wxml文件 <scroll-view scroll-top="{{scrollTop}}" scroll-y="true& ...

  6. Objective C HMAC-MD5

    - (NSString*) HMACWithSecret:(NSString*) secret andString:(NSString *)str { unsigned long encode = C ...

  7. MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法 -摘自网络

    错误:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 原因: 同一个i ...

  8. Laravel5 model create使用

    1.在laravel的Eloquent ORM中,默认表会有created_at.updated_at两个字段,因此在使用create函数时若表无这两个字段会出错,可以设置 public $times ...

  9. MapReduce 简单的全文搜索

    上一个已经实现了反向索引,那么为什么不尝试下全文搜索呢.例如有了 Hello     file3.txt:1; MapReduce     file3.txt:2;fil1.txt:1;fil2.tx ...

  10. Apache Mina(二)

    在mina的源码,整个框架最核心的几个包是 : org.apache.mina.core.service :IoService.IoProcessor.IoHandler.IoAcceptor.IoC ...