B. Blown Garland
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.
InputThe 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.
OutputIn the only line print four integers kr, kb, ky, kg — the number of dead light bulbs of red, blue, yellow and green colors accordingly.
ExamplesinputRYBGRYBGRoutput0 0 0 0input!RGYBoutput0 1 0 0input!!!!YGRBoutput1 1 1 1input!GB!RG!Y!output2 1 1 0NoteIn 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.
题目比较简单 每个位置%4就可以找出来连续的四种颜色,之所以挂出来是因为第一次学会了用字符表示数组地址。
附AC代码:
#include<bits/stdc++.h>
using namespace std; char a[];
int c[]; int main(){
// ios::sync_with_stdio(false);
ios::sync_with_stdio(false);
string s;
cin>>s;
int r,y,b,g;
int len=s.size();
for(int i=;i<len;i++){
if(s[i]!='!'){
a[i%]=s[i];
}
}
for(int i=;i<len;i++){
if(s[i]=='!'){
c[a[i%]]++;
}
}
cout<<c['R']<<" "<<c['B']<<" "<<c['Y']<<" "<<c['G']<<endl;
return ;
}
B. Blown Garland的更多相关文章
- 758B Blown Garland
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 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 ...
- 【codeforces 758B】Blown Garland
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 758B Blown Garland
题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就 ...
- Codeforces 758B:Blown Garland(模拟)
http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的 ...
- Codeforces 392 B Blown Garland
题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯.简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然 ...
- Codeforces758B
B. Blown Garland time limit per test:1 second memory limit per test:256 megabytes input:standard inp ...
- 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 ...
- POJ 1759 Garland(二分+数学递归+坑精度)
POJ 1759 Garland 这个题wa了27次,忘了用一个数来储存f[n-1],每次由于二分都会改变f[n-1]的值,得到的有的值不精确,直接输出f[n-1]肯定有问题. 这个题用c++交可以 ...
随机推荐
- 一道题目- Find the smallest range that includes at least one number from each of the k lists
You have k lists of sorted integers. Find the smallest range that includes at least one number from ...
- IntelliJ IDEA cannot resolved 处理
IntelliJ IDEA cannot resolved 处理 学习了:https://stackoverflow.com/questions/21577573/intellij-idea-can- ...
- 关于Memcached的CAS和Set方法造成Socket泄漏的问题
为了解决多并发下写Memcached的冲突方案,我们项目组引入了CAS机制.类同于Java并发包中的CAS(Compareand set)原子操作,用来处理同一个Item被多个线程更改的并发问题.Me ...
- poj 1694 An Old Stone Game 树形dp
//poj 1694 //sep9 #include <iostream> #include <algorithm> using namespace std; const in ...
- oracle下session的查询与删除
oracle下session的查询与删除 1.查询当前session SQL> select username,sid,serial# from v$session where username ...
- redux 及 相关插件 项目实战
目录结构 +-- app | +-- actions | +-- index.js | +-- components | +-- content.js | +-- footer.js | +-- se ...
- 6.非关系型数据库(Nosql)之mongodb:集群(主从复制)
1.主从复制是MongoDB最经常使用的复制方式.这样的方式很灵活,可用于备份.故障恢复.读扩展等 2最主要的设置方式就是建立一个主节点和一个或多个从节点,每一个从节点要知道主节点的地址. 执行 ...
- 面试-1-C#浅解
面试-1 C#浅解众所周知c#是微软推出的一款完全没面向对象的编程语言,那么对象是什么?在现实生活中人们一提到对象首先想到的就是“情侣”!但是在我们的程序中对象是什么? 在程序中个能够区别于其他事 ...
- 使用ucontext组件实现的coroutine代码分析
coroutine一般翻译过来就是协程,类似于线程可以切换,而跟线程是由操作系统调度器来实现切换不一样,协程由用户程序自己调度进行切换.我以前也看过协程相关的内容,但没有自己去实现过.最近搞OpenS ...
- GuozhongCrawler系列教程 (5) TransactionRequest具体解释
为了实现和维护并发抓取的属性信息提供线程安全的事务请求.TransactionRequest是一个抽象类自己不能设置Processor,却须要实现 TransactionCallBack接口.Tran ...