Codeforces758B Blown Garland 2017-01-20 10:19 87人阅读 评论(0) 收藏
1 second
256 megabytes
standard input
standard 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.
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.
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.
RYBGRYBGR
0 0 0 0
!RGYB
0 1 0 0
!!!!YGRB
1 1 1 1
!GB!RG!Y!
2 1 1 0
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.
YBGRYBGRYBG,
BGRYB,!表示坏了的灯
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string> using namespace std; char a[1006];
int main()
{
while(~scanf("%s",a))
{
int k=strlen(a);
int r,g,b,y;
int c[10005];
int cnt=0;
for(int i=0; i<k; i++)
{
if(a[i]=='!')
{
c[cnt++]=i;
}
else if(a[i]=='R')
{
r=i;
}
else if(a[i]=='G')
{
g=i;
}
else if(a[i]=='B')
{
b=i;
} else if(a[i]=='Y')
{
y=i;
}
}
r%=4;
g%=4;
b%=4;
y%=4;
int R=0,G=0,B=0,Y=0;
for(int i=0;i<cnt;i++)
{
if(c[i]%4==r)
R++;
else if(c[i]%4==g)
G++;
else if(c[i]%4==b)
B++;
else if(c[i]%4==y)
Y++;
}
printf("%d %d %d %d\n",R,B,Y,G);
}
return 0;
}
Codeforces758B Blown Garland 2017-01-20 10:19 87人阅读 评论(0) 收藏的更多相关文章
- ubuntu中安装eclipse 分类: android ubuntu linux 学习笔记 2015-07-07 10:19 75人阅读 评论(0) 收藏
上一篇说了安装jdk的事,于是趁热打铁,决定把eclipse也安装了. 下载这一系列就不用说了. 下载完成之后: 然后解压,解压之后文件剪切到/usr/software文件夹中,同时重命名为eclip ...
- sscanf 函数 分类: POJ 2015-08-04 09:19 4人阅读 评论(0) 收藏
sscanf 其实很强大 分类: 纯C技术 技术笔记 2010-03-05 16:00 12133人阅读 评论(4) 收藏 举报 正则表达式stringbuffercurlgoogle 最近在做日志分 ...
- 博弈论入门小结 分类: ACM TYPE 2014-08-31 10:15 73人阅读 评论(0) 收藏
文章原地址:http://blog.csdn.net/zhangxiang0125/article/details/6174639 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...
- C语言基础总结 分类: iOS学习 c语言基础 2015-06-11 10:08 23人阅读 评论(0) 收藏
//欲练此功必先自宫!!! //第一天:C语言的基础 //进制 //2进制, 10进制, 8进制, 16进制 //注:8进制数前加0, 16进制数前加0x ...
- Financial Management 分类: POJ 2015-06-11 10:51 12人阅读 评论(0) 收藏
Financial Management Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 164431 Accepted: ...
- Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 108765 Accepted: 53009 Descr ...
- DateTime日期格式获取 分类: C# 2014-04-15 10:36 233人阅读 评论(0) 收藏
c#.net 获取时间年月日时分秒格式 //获取日期+时间 DateTime.Now.ToString(); // 2008-9-4 20:02:10 DateTime.Now. ...
- winform timespan 两个时间的间隔(差) 分类: WinForm 2014-04-15 10:14 419人阅读 评论(0) 收藏
TimeSpan 结构 表示一个时间间隔. 先举一个小例子:(计算两个日期相差的天数) 代码如下: DateTime dt = DateTime.Now.ToShortDateString(yyyy ...
- iOS开发:创建真机调试证书 分类: ios相关 2015-04-10 10:22 149人阅读 评论(0) 收藏
关于苹果iOS开发,笔者也是从小白过来的,经历过各种困难和坑,其中就有关于开发证书,生产证书,in_house证书,add_Hoc证书申请过程中的问题,以及上架发布问题.今天就着重说一下关于针对于苹果 ...
随机推荐
- Scala语言学习笔记(3)
类 // 定义并使用类 class User val user1 = new User // 主体构造器(primary constructor) class Point(var x: Int, va ...
- Rust语言学习笔记(4)
Variables and Mutability(变量和可变性) 变量声明有三种:不变量(运行期的常量),变量以及(编译期的)常量. 变量可以重复绑定,后声明的变量覆盖前面声明的同名变量,重复绑定时可 ...
- mysql in 过滤 解决转义问题
IF(headUser!='',instr(concat(',',headUser,','),concat(',',cr.headUser,',')),TRUE);
- js获取或判断任意数据类类型的通用方法(getDataType)和将NodeList转为数组(NodeListToArray)
function getDataType(any){ /* (1) Object.prototype.toString.call 方法判断类型: 优点:通用,返回"[object Strin ...
- 与servlet相关的接口
(二)与servlet相关的接口 从servlet仅有的5个方法当中,我们知道其涉及3个接口,分别是: ServletConfig ServletRequest ServletResponse 2.1 ...
- c++实现贪食蛇
今天老师布置了作业 让我们观察c++实现贪食蛇的代码 #include<windows.h> #include<time.h> #include<stdlib.h> ...
- 使用github的流程
使用github的流程 在实际项目开发中,按照如下步骤使用git进行代码管理 1.项目经理在开发之初,创建好仓库,上传项目的框架.组员分支 2.组员克隆项目框架,同步分支,按分工开发,在分支提交代码 ...
- chnagyong sql
select gid,count(distinct mid) from members group by gid mysql> SELECT IFNULL(NULL,); mysql> 1 ...
- zg项目 应用系统编码原则
一.编码说明: 1.系统编码采用三码为原则,通常两码简称之. 1>.子系统或类型 2>.系统小分类 3>.系统大分类 如 IPMS领域业务群: DA 应用软件发展管理系统 DE公用副 ...
- Centos 安装Mongo DB
NOSQL在很短的时间里使用人数据高涨,这不仅是它提出的一种新存储思想,更是因为它在对大数据做操作的效率,明显高于关系数据库 工具/原料 接入Internet的一台Centos计算机 下载安装文件 ...