题目链接: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. TCP通讯模型简单示例

    1. TCP通讯模型 2. 服务器端 ① 创建socket,用函数socket() ② 绑定IP地址.端口号等信息到socket上,用函数bind() ③ 设置允许的最大连接数,用函数listen() ...

  2. Problem04 分解质因数

    题目:将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成: (1)如果这个质数恰等于n,则说明分解质因数的 ...

  3. 利用vue-cli搭建vue项目

    手把手教你用vue-cli搭建vue项目 本篇主要是利用vue-cli来搭建vue项目,其中前提是node和npm已经安装好,文章结尾将会简单提到一个简单的例子.使用vue-cli搭建项目最开始我也是 ...

  4. Eclipse中项目报Target runtime com.genuitec.runtime.generic.jee60 is not defined异常的解决

    参考 http://843977358.iteye.com/blog/2295344

  5. 3d Max 2019安装失败怎样卸载3dsmax?错误提示某些产品无法安装装

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  6. Unity Scene Screen.resolutions 分辨率列表

    Screen.resolutions 分辨率列表(安卓平台试了不能用此方法,最好用宏定义判断一下平台) C# => public static Resolution[] resolutions; ...

  7. Django重新整理2

    Auth认证: 1.分配路由和创建视图函数 2.在视图函数中引用Django为我们提供的用户认证组建Auth 3.直接进行判断: def login(request): if request.meth ...

  8. [转]怎么样快速入门AngularJS?

    本文转自:http://www.ngnice.com/posts/205af1ea1e13d2 怎么样快速学习AngularJS? 相信很多初学者都有过或者类似的疑问,其实这个问题没有标准的答案,每个 ...

  9. Huawei English Corner

     Keywords  Descriptions  FWIW  For what it's worth(不管结果怎样)  ASAP  As Soon As Possible(尽快)  FYI  For ...

  10. Kudu compaction design

    不多说,直接上干货! http://blog.csdn.net/lookqlp/article/details/51438109