题目链接: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. php数组·的方法-数组检索

    /* * //数组检索函数 * */ //array_keys() 获取数组中所有键名 //array_values() 获取数组中所有键名 $arr6=range('a','e'); print_r ...

  2. java——arr == null || arr.length == 0

    这两者是不同的: arr == null; int[] arr = null; arr.length == 0; int[] arr =new int[0];

  3. SQL---MySQL数据库---聚合函数

    1.数值 format(x,n) 将x格式化为  由逗号分隔,小数点后n 位的数:

  4. mysql 死锁解决办法

    查询表的时候,发现一圈圈转啊转,就是不出来数据,猜测表被锁住 解决办法 : mysql> show processlist ; mysql> kill 4;       说明 : 4为 i ...

  5. android通过Jni加载so库遇到UnsatisfiedLinkError问题!!!

    错误信息: java.lang.UnsatisfiedLinkError: hsl.p2pipcam.nativecaller.NativeCaller at hsl.p2pipcam.manager ...

  6. Mac 系统变量

    vim .bash_profile ========================= MAVEN_HOME = < ... > export MAVEN_HOME =========== ...

  7. UGUI EventSystem.current.IsPointerOverGameObject(),判断是否进入了UI上

    EventSystem.current.IsPointerOverGameObject(); //返回一个布尔值,进入了UI上就返回true,用的时候要 using UnityEngine.Event ...

  8. [转]JS对JSON的操作总结

    本文转自:http://www.cnblogs.com/csj222/archive/2013/04/11/3013667.html 对于前端完全是菜鸟,迫于无奈,工作中要用到JS,尤其对JSON的处 ...

  9. Horizon

    python manage.py compress python manage.py collectstatic {% extends "horizon/common/_modal_form ...

  10. css 动画 和 响应式布局和兼容性

    14.动画 -moz-:火狐, -ms-:IE,-webkit-:谷歌,-o-:欧朋 transform旋转 rotate旋转 scale放大 translate偏移量 skew倾斜度 transfo ...