codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

758B.md (2480B)


      1 Source: https://codeforces.com/problemset/problem/758/B
      2 
      3 B. Blown Garland
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
     22 
     23 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.
     24 
     25 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.
     26 
     27 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.
     28 
     29 Input
     30 
     31 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:
     32 
     33 * 'R' — the light bulb is red,
     34 * 'B' — the light bulb is blue,
     35 * 'Y' — the light bulb is yellow,
     36 * 'G' — the light bulb is green,
     37 * '!' — the light bulb is dead.
     38 
     39 The string *s* can not contain other symbols except those five which were described.
     40 
     41 It is guaranteed that in the given string at least once there is each of four letters 'R', 'B', 'Y' and 'G'.
     42 
     43 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.
     44 
     45 Output
     46 
     47 In the only line print four integers *k**r*, *k**b*, *k**y*, *k**g* — the number of dead light bulbs of red, blue, yellow and green colors accordingly.
     48 
     49 Examples
     50 
     51 Input
     52 
     53 ```
     54 RYBGRYBGR
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 0 0 0 0
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 !RGYB
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 0 1 0 0
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 !!!!YGRB
     79 ```
     80 
     81 Output
     82 
     83 ```
     84 1 1 1 1
     85 ```
     86 
     87 Input
     88 
     89 ```
     90 !GB!RG!Y!
     91 ```
     92 
     93 Output
     94 
     95 ```
     96 2 1 1 0
     97 ```
     98 
     99 Note
    100 
    101 In the first example there are no dead light bulbs.
    102 
    103 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.