题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯。简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然后分别输出坏了的红、蓝、黄、绿灯的数量。

分析:因为下标对4取余相同的灯颜色都相同,所以确定了前四个灯的颜色,后面的灯都是前四个灯颜色的不断循环,两个map映射一下就可以了。

#include<bits/stdc++.h>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const int dr[] = {, , -, , -, -, , };
const int dc[] = {-, , , , -, , -, };
const int MOD = 1e9 + ;
const double pi = acos(-1.0);
const double eps = 1e-;
const int MAXN = + ;
const int MAXT = + ;
using namespace std;
char s[MAXN];
map<int, char> mp;
map<char, int> ma;
int a[];
int main(){
ma['R'] = ;
ma['B'] = ;
ma['Y'] = ;
ma['G'] = ;
while(scanf("%s", s) == ){
mp.clear();
memset(a, , sizeof a);
int len = strlen(s);
for(int i = ; i < len; ++i){//确定前四个灯的颜色
if(i % == && s[i] != '!'){
mp[] = s[i];
}
if(i % == && s[i] != '!'){
mp[] = s[i];
}
if(i % == && s[i] != '!'){
mp[] = s[i];
}
if(i % == && s[i] != '!'){
mp[] = s[i];
}
}
for(int i = ; i < len; ++i){
if(s[i] == '!'){
int t = i % ;
char c = mp[t];//每个坏了的灯分别是什么颜色,并统计个数
++a[ma[c]];
}
}
printf("%d %d %d %d\n", a[], a[], a[], a[]);
}
return ;
}

Codeforces 392 B Blown Garland的更多相关文章

  1. 【codeforces 758B】Blown Garland

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. Codeforces 758B:Blown Garland(模拟)

    http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的 ...

  3. 758B Blown Garland

    B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  4. 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 ...

  5. Codeforces 758B Blown Garland

    题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就 ...

  6. B. Blown Garland

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  7. 1.23 codeforces div3 C.Nice Garland

    You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...

  8. CF codeforces A. New Year Garland【Educational Codeforces Round 79 (Rated for Div. 2)】

    A. New Year Garland time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. codeforces 140E.New Year Garland

    传送门: 解题思路: 要求相邻两行小球颜色集合不同,并且限制行内小球相邻不同. 由此可得:每行小球排列都是独立与外界的, 所以答案应该是对于所有行的颜色集合分类,在将行内的答案乘到上面. 先考虑如何分 ...

随机推荐

  1. JDBC--DAO设计模式

    1.DAO(Data Access Object):访问数据信息的类,包含对数据的CRUD(Create.Read.Update.Delete),而不包含任何业务相关的信息. --DAO能够实现功能的 ...

  2. windows下用libevent 开发一个echo服务

    #include <stdio.h> #include <string.h> #include <errno.h> #include <iostream> ...

  3. Day10 - C - Blow up the city HDU - 6604

    Country A and B are at war. Country A needs to organize transport teams to deliver supplies toward s ...

  4. Redis详解(一)——RDB

    Redis详解(一)--RDB 前言 由于 Redis 是一个内存数据库,所谓内存数据库,就是将数据库中的内容保存在内存中,这与传统的MySQL,Oracle等关系型数据库直接将内容保存到硬盘中相比, ...

  5. 六种方式实现hibernate查询,及IDE推荐

      这些天过的好乱,也许是因为考完试了,心里有些松懈吧.也许是最近发生的事对我有些触动吧.感觉自己都已经不懂自己了.面对一些人的教导,我很感激.因为很多话都对我有非常大的帮助和启发,也让我除了做技术, ...

  6. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 按钮:按钮组

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. hdu 1533 Going Home 最小费用最大流 (模板题)

    Going Home Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  8. P1069 微博转发抽奖

    P1069 微博转发抽奖 转跳点:

  9. pytorch max和clamp

    torch.max() torch.max(a):数组a的最大值 torch.max(a, dim=1):多维数组沿维度1方向上的最大值,若a为二维数组,则为每行的最大值(此时是对每行的每列值比较取最 ...

  10. 南邮平台之Hello,RE!

    小白闲逛了一下南邮平台看到了逆向这题,小白在网上看了一下别人的write up发现有点复杂.于是小白就试试看,直接Underfine然后结果就出来了.....有点意外...... 结果flag{Wel ...