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证书申请过程中的问题,以及上架发布问题.今天就着重说一下关于针对于苹果 ...
随机推荐
- Why We Worry and What to Do About It
Note: My new book Atomic Habits is available to preorder now. Click here to learn more. The Evolutio ...
- 吴裕雄 数据挖掘与分析案例实战(4)——python数据处理工具:Pandas
# 导入模块import pandas as pdimport numpy as np # 构造序列gdp1 = pd.Series([2.8,3.01,8.99,8.59,5.18])print(g ...
- 有名管道FIFO
管道和FIFO的特征之一是它们的数据是一个字节流.这是UNIX的原生I/O模型.进程往其中写入的是字节流,系统不对它作解释. FIFO不存数据,只是通过它找到内核文件. 一.建立有名管道 1.命令mk ...
- Parametric Statistics
1.What are “Parametric Statistics”? 统计中的参数指的是总体的一个方面,而不是统计中的一个方面,后者指的是样本的一个方面.例如,总体均值是一个参数,而样本均值是一个统 ...
- cdoj842-天下归晋 【树状数组】
http://acm.uestc.edu.cn/#/problem/show/842 天下归晋 Time Limit: 3000/1000MS (Java/Others) Memory Lim ...
- 在java中使用ffmpeg将amr格式的语音转为mp3格式
ffmpeg是一个非常强大的音视频处理工具,官网是:http://ffmpeg.org/. 由于ffmpeg在windows上和linux系统上的执行文件不一样(Windows上不需要安装ffmpeg ...
- 【原创】Junit4详解二:Junit4 Runner以及test case执行顺序和源代码理解
概要: 前一篇文章我们总体介绍了Junit4的用法以及一些简单的测试.之前我有个疑惑,Junit4怎么把一个test case跑起来的,在test case之前和之后我们能做些什么? Junit4执行 ...
- php单点登陆简单实现 (iframe方式)
有四个网站分别为: www.a.com www.b.com www.c.com www.sso.com 需求是如果我们在sso登陆后,其他网站也会显示登陆中,不需要重复登陆,退出时,其他网站也会失效. ...
- php libevent 详解与使用
libevent是一个基于事件驱动的高性能网络库.支持多种 I/O 多路复用技术, epoll. poll. dev/poll. select 和 kqueue 等:支持 I/O,定时器和信号等事件: ...
- PAT 1078 字符串压缩与解压(20)(代码+思路)
1078 字符串压缩与解压(20 分) 文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一个连续的片段用这个字符和片段中含有这个字符的个数来表示.例如 ccccc 就用 5c 来表 ...