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++交可以 ...
随机推荐
- 从SOA到BFV【普元的一份广告文章】
人类对美好生活的追求是一切技术进步的原动力. 简便.快捷.联结……,这些移动互联的价值让它正成为最贴近消费者的力量.人和设备,设备和设备,人和服务,人和企业,企业和企业都发生了连接.诸如微信.携程.大 ...
- SqlServer 数据恢复
首先看看微软官方的给出的建议(摘自:http://technet.microsoft.com/zh-cn/library/ms189272.aspx): 在从完整恢复模式或大容量日志恢复模式切换前,请 ...
- Intel Edision —— 上电、基本设置与系统初探
前言 原创文章,转载引用务必注明链接.如有疏漏,欢迎斧正. Intel的文档其实挺清楚了,坛子上很多人把文档又详细复述一边,私以为一篇就够了其他的跟着文档走一遍也挺好的...俗一把使用过程顺手记录下来 ...
- Indri和Terrier搜索引擎的使用
介绍 Indri和Terrier都是开源的搜索引擎,当中Indri作为Lemur项目的一个重要部分,具有强大的查询接口,易建索引,可扩展,高效率等长处.能够在SourceForge Lemur Pro ...
- PHP生成excel(3)
这一节主要是设置背景颜色.边框.字体大小.表格宽度 效果图 代码如下 <?php header("Content-Type:text/html;charset=utf-8") ...
- codeforces#FF(div2) D DZY Loves Modification
首先要知道选择行列操作时顺序是无关的 用两个数组row[i],col[j]分别表示仅选择i行能得到的最大值和仅选择j列能得到的最大值 这个用优先队列维护,没选择一行(列)后将这行(列)的和减去对应的n ...
- 使用MegaCli查看raid信息
LSI SAS based MegaRAID driver http://www.lsi.com/downloads/Public/Nytro/downloads/Nytro%20XD/MegaCli ...
- HDU 1257:最少拦截系统
最少拦截系统 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- MYSQL进阶学习笔记九:MySQL事务的应用!(视频序号:进阶_21-22)
知识点十:MySQL 事务的应用 (21-22) 为什么要引入事务: 为什么要引入事务这个技术呢?现在的很多软件都是多用户,多程序,多线程的.对同一表可能同时有很多人在用,为保持数据的一致性,所以提出 ...
- linux初级学习笔记四:Linux文件管理类命令详解!(视频序号:03_1)
本节学习的命令:cat(tac),more,less,head,tail,cut,sort,uniq,wc,tr 本节学习的技能:目录管理 文件管理 日期时间 查看文本 分屏显示 文本处理 文件管理命 ...