题目链接:http://codeforces.com/contest/758/problem/B

题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少。

分析:就是要找出这个链子是那个部分。那么就有4!种可能。

 #include <bits/stdc++.h>

 using namespace std;

 char str[][] =
{
"BGRY",
"BGYR",
"BRGY",
"BRYG",
"BYGR",
"BYRG",
"GBRY",
"GBYR",
"GRBY",
"GRYB",
"GYBR",
"GYRB",
"RBGY",
"RBYG",
"RGBY",
"RGYB",
"RYBG",
"RYGB",
"YBGR",
"YBRG",
"YGBR",
"YGRB",
"YRBG",
"YRGB",
}; int cnt[];
int color[]; int main()
{
char cmp[];
scanf("%s",cmp);
int len = strlen(cmp);
for(int i=;i<len;i++) {
for(int j=;j<;j++) {
if(str[j][i%]==cmp[i])
cnt[j]++;
}
} int id;
int tmp = -;
for(int i=;i<;i++) {
if(tmp<cnt[i])
{
tmp = cnt[i];
id = i;
}
} for(int i=;i<len;i++)
if(str[id][i%]!=cmp[i])
color[i%] ++; int Rid;
for(int r=;r<;r++)
{
if(str[id][r]=='R')
Rid = r;
} int Bid;
for(int r=;r<;r++)
{
if(str[id][r]=='B')
Bid = r;
} int Yid;
for(int r=;r<;r++)
{
if(str[id][r]=='Y')
Yid = r;
} int Gid;
for(int r=;r<;r++)
{
if(str[id][r]=='G')
Gid = r;
} printf("%d %d %d %d\n",color[Rid],color[Bid],color[Yid],color[Gid]); return ;
}

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

  1. 758B Blown Garland

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

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

  3. 【codeforces 758B】Blown Garland

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

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

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

  5. Codeforces 392 B Blown Garland

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

  6. Codeforces 1108D - Diverse Garland - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...

  7. B. Blown Garland

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

  8. 【codeforces 767C】Garland

    [题目链接]:http://codeforces.com/contest/767/problem/C [题意] 一棵树; 树上的每个节点都有一个权值; 让你把一棵树切掉两条边; 然后把这棵树分成了3个 ...

  9. codeforces 1283F. DIY Garland(树+优先队列)

    题目连接:https://codeforces.com/contest/1283/problem/F 题意:一根电线连接着两个点,这两个点分别代表着两个灯,灯有自己的编号i,其亮度是2 ^ i,每根电 ...

随机推荐

  1. google chrome浏览器自动填充解决方案

    在chrome浏览器中,浏览器对于[1]type为password和text的.[2]带有name或者id属性的<input>标签会有自动填充表单功能,虽然会给用户记住密码带来一定的便利, ...

  2. MySQL之prepare用法

    MySQL官方将prepare.execute.deallocate统称为PREPARE STATEMENT,习惯称其为[预处理语句],下面是对其详细的介绍. 示例代码 PREPARE stmt_na ...

  3. Apache重定向URL

    (1)去除httpd.conf文件中"#LoadModule rewrite_module modules/mod_rewrite.so"前面的"#"号; (2 ...

  4. 时间戳date 命令

    时间戳date  命令 [chenxiaohao@iZbp1c0q444r0hp2gq8lhmZ server]$ echo $(date +%Y%m%d)  ——————>今天 2018032 ...

  5. pip install keras==1.2.1

    [该方法仅适用于压缩包中含有setup.py的情况] 先从GitHub上找到想要下载的历史版本,右键复制链接地址. 然后执行命令: pip install https://github.com/ker ...

  6. Cache一致性协议之MESI

    http://blog.csdn.net/muxiqingyang/article/details/6615199 Cache一致性协议之MESI 处理器上有一套完整的协议,来保证Cache一致性.比 ...

  7. Murano Weekly Meeting 2015.09.22

    Meeting time: 2015.September.22th 1:00~2:00 Chairperson:  Serg Melikyan, PTL from Mirantis Meeting s ...

  8. zookeeper开源客户端curator

    zookeeper的原生api相对来说比较繁琐,比如:对节点添加监听事件,当监听触发后,我们需要再次手动添加监听,否则监听只生效一次:再比如,断线重连也需要我们手动代码来判断处理等等.对于curato ...

  9. 定制Linux

    tar -xzvf linux-major-minor-VERSION.tar.gz -C /usr/src cd /usr/src ln -sv linux-major-minor-VERSION ...

  10. supermarket SSM

    1.数据库 2.整体空架构(jar包) 3.工程依赖 24节点 build节点 <properties> </project.build.sourceEncoding> < ...