zoukankan      html  css  js  c++  java
  • Codeforces758B

    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.

     1 //2017.01.19
     2 #include <iostream>
     3 #include <cstdio>
     4 #include <cstring>
     5 
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     string light;
    11     int k[10];
    12     char l[4] = {'r', 'b', 'y', 'g'};
    13     int order[4];
    14     while(cin >> light)
    15     {
    16         int cnt = 0;
    17         memset(order, 0, sizeof(order));
    18         memset(k, 0, sizeof(k));
    19         for(int i = 0; i < light.length(); i++)
    20         {
    21             if(light[i] != '!')
    22             {
    23                 if(light[i] == 'R')order[i%4] = 1;
    24                 else if(light[i] == 'B')order[i%4] = 2;
    25                 else if(light[i] == 'Y')order[i%4] = 3;
    26                 else if(light[i] == 'G')order[i%4] = 4;
    27             }
    28         }
    29         for(int i = 0; i < light.length(); i++)
    30         {
    31             if(light[i] == '!')
    32                   k[order[i%4]]++;
    33         }
    34         for(int i = 1; i <= 4; i++)
    35               if(i == 4)cout<<k[i]<<endl;
    36             else cout<<k[i]<<" ";
    37     }
    38 
    39     return 0;
    40 }
  • 相关阅读:
    阿里测试工程师教你自动化测试如何准备测试数据
    同一个tomcat下部署多个springboot项目时,springboot项目无法正常启动的问题
    ant desgin pro 跨页面传参
    富兰克林的人生信条
    node 一拉管理工具 yarn安装(npm的替代品)
    python pip 安装包下载过慢的解决方法 socket.timeout: The read operation timed out
    springBoot 文件下载
    Excel无法打开文件xxx.xlsx,因为文件格式或文件扩展名无效。请确定文件未损坏,并且文件扩展名与文件的格式匹配
    MYSQL like 模糊查询 分字查询
    人人译视界-给视频添加srt字幕
  • 原文地址:https://www.cnblogs.com/Penn000/p/6322156.html
Copyright © 2011-2022 走看看