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++交可以 ...
随机推荐
- SpringMVC拦截器详解[附带源码分析](转)
本文转自http://www.cnblogs.com/fangjian0423/p/springMVC-interceptor.html 感谢作者 目录 前言 重要接口及类介绍 源码分析 拦截器的配置 ...
- 【C#】RGB,CMYK,HSB各种颜色表示的转换(转)
[C#]RGB,CMYK,HSB各种颜色表示的转换 一.表示颜色的方式有很多种,如RGB,CMYK,HSB,Hex等等 1.RGB:这种表示颜色由三原色构成,通过红,绿,蓝三种颜色分量的不同,组合 ...
- [转】 nginx rewrite规则
http://www.cnblogs.com/cgli/archive/2011/05/16/2047920.html 最近在VPS上尝试配置安装一个网站,VPS安装了LNMP(Linux+Nginx ...
- aSmack连接server异常smack.SmackException$ ConnectionException thrown by XMPPConnection.connect();
以下是我在研究asmack4.0出现的异常 06-17 12:02:56.924: W/System.err(10622): org.jivesoftware.smack.SmackException ...
- sshd登录攻击
先说简单的防范措施: 1.密码足够复杂 密码的长度大于8位.有数字.大小写字母.特殊字符组合. 2.nmap 扫描 为了避免被扫描到, #看到端口是81 ssh root@192.168.1.63 玩 ...
- c++中vector向量几种情况的总结(向量指针,指针的向量)
1.标准库vector类型 vector 是同一种类型的对象的集合.每一个对象都有一个相应的整数索引值.标准库将负责管理与存储元素相关的内存.我们把 vector 称为容器,是由于它能够包括其它对象. ...
- shell mysql 直接创建表
shell 直接创建表 #!/bin/bash mysql -hdatabases -uroot -p^xxxxasdasdadd <<EOF Create Database If Not ...
- mysql中游标在存储过程中的具体使用方法
昨天写的一个东东,分享下给大家. drop PROCEDURE if exists sp_cleanUserData; CREATE PROCEDURE `sp_cleanUserData`() ...
- Indri和Terrier搜索引擎的使用
介绍 Indri和Terrier都是开源的搜索引擎,当中Indri作为Lemur项目的一个重要部分,具有强大的查询接口,易建索引,可扩展,高效率等长处.能够在SourceForge Lemur Pro ...
- 删除moduleCache下文件解决预编译头文件相关的编译错误
之前有在代码全部正确的情况下,遇到过下面的编译错误: fatal error: file '.....h' has been modified since the precompiled header ...