time limit per test1 second

memory limit per test256 megabytes

inputstandard input

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

【题目链接】:http://codeforces.com/contest/758/problem/B

【题解】



枚举前4个的排列;

4!

然后根据前4个推出整个序列应该是什么;

看看合法不合法;

合法的话看!对应的是什么;输出就好了;

4!*100;

肯定不超;



【完整代码】

#include <bits/stdc++.h>

using namespace std;

string ts,s;
bool bo[4];
int len,ans[4]; bool ok(string ss)
{
// cout << len << endl;
// cout << ss <<endl;
int tlen = 0;
string ts2="";
while (tlen<len)
{
ts2+=ss;
tlen+=4;
}
for (int i = 0;i <= len-1;i++)
if (s[i]!='!' && s[i]!=ts2[i])
return false;
for (int i = 0;i <= len-1;i++)
if (s[i]=='!')
{
if (ts2[i]=='R')
ans[0]++;
if (ts2[i]=='B')
ans[1]++;
if (ts2[i]=='Y')
ans[2]++;
if (ts2[i]=='G')
ans[3]++;
}
for (int i = 0;i<=2;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[3]);
return true;
} void sear_ch(int now,string temp)
{
if (now==4)
{
if (ok(temp))
exit(0);
return;
}
for (int i =0;i<=3;i++)
if (!bo[i])
{
bo[i] = true;
sear_ch(now+1,temp+ts[i]);
bo[i] = false;
}
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> s;
len = s.size();
ts = "RBYG";
memset(bo,false,sizeof bo);
sear_ch(0,"");
return 0;
}

【codeforces 758B】Blown Garland的更多相关文章

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

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

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【codeforces 767C】Garland

    [题目链接]:http://codeforces.com/contest/767/problem/C [题意] 一棵树; 树上的每个节点都有一个权值; 让你把一棵树切掉两条边; 然后把这棵树分成了3个 ...

  4. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  5. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  6. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  7. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  8. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  9. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

随机推荐

  1. 【习题 7-1 UVA-208】Firetruck

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 预处理一下终点能到达哪些点. 暴力就好. 输出结果的时候,数字之间一个空格.. [代码] /* 1.Shoud it use lon ...

  2. COGS——T 1265. [NOIP2012] 同余方程

    http://cogs.pro/cogs/problem/problem.php?pid=1265 ★☆   输入文件:mod.in   输出文件:mod.out   简单对比时间限制:1 s   内 ...

  3. 巧用数据流让 Word 文档在线阅读

            常常写博客或空间日记的朋友,对网络编辑器(如图1,是CSDN的博客编辑器)并不陌生.也比較easy做出非常绚烂的排版.但这次在做一个BS的项目,客户一直在用Office的软件中的Wor ...

  4. iptables转发安卓手机热点的数据到指定的端口

    iptables转发安卓手机热点的数据到指定的端口 手机安装了VPN,可以上GOOGLE的那种.然后我打开手机的热点,连上笔记本,想让本本上个google 没想到被GFW挡住了.看了一下手机的网络工作 ...

  5. 程序是怎么跑起来的? —— CPU 是什么?C/C++程序的运行

    1. 概念初步 程序:计算机的程序,和做饭.运动会的程序一样,指的是"做事的先后次序": 程序的组成:程序是指令(及物动词)和数据(宾语)的组合体: C 语言 printf(&qu ...

  6. 报错 关于python的x和y不等长

    ValueError: shape mismatch: objects cannot be broadcast to a single shape 这个错误可能是因为传入的两个参数数据长度不一样,比如 ...

  7. 浅谈Normalize.css

    浅谈Normalize.css 一.总结 1.Normalize.css:它在默认的HTML元素样式上提供了跨浏览器的高度一致性,花了几百个小时来努力研究不同浏览器的默认样式的差异. 2.优于rese ...

  8. 语言模型(Language Modeling)与统计语言模型

    1. n-grams 统计语言模型研究的是一个单词序列出现的概率分布(probability distribution).例如对于英语,全体英文单词构成整个状态空间(state space). 边缘概 ...

  9. (转)看懂类图——UML类图基础

    类图 要学懂设计模式,就需要先看得懂类图,类与类之间的关系是学习设计模式的基础,而在软件工程中,类与类之间的关系是通过UML中的类图来体现. 这篇笔记包含的不会是类图的所有东西,包含的只是各个类之间的 ...

  10. μC/OS中的任务就绪表

    为了便于对就绪表的查找,μC/OSII又定义了一个数据类型为INT8U的变量OSRdyGrp, 并使该变量的每一位都对应OSRdyTbl[ ]的一个任务组(即数组的一个元素),如果某任务组中 有任务就 ...