Codeforces 758B Blown Garland
题目链接: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的更多相关文章
- 758B Blown Garland
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 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 ...
- 【codeforces 758B】Blown Garland
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 758B:Blown Garland(模拟)
http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的 ...
- Codeforces 392 B Blown Garland
题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯.简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然 ...
- Codeforces 1108D - Diverse Garland - [简单DP]
题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...
- B. Blown Garland
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【codeforces 767C】Garland
[题目链接]:http://codeforces.com/contest/767/problem/C [题意] 一棵树; 树上的每个节点都有一个权值; 让你把一棵树切掉两条边; 然后把这棵树分成了3个 ...
- codeforces 1283F. DIY Garland(树+优先队列)
题目连接:https://codeforces.com/contest/1283/problem/F 题意:一根电线连接着两个点,这两个点分别代表着两个灯,灯有自己的编号i,其亮度是2 ^ i,每根电 ...
随机推荐
- Python中的数据类型和数据结构
一.数据类型 Python中有六个标准数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionary(字典) 其中,除列表Lis ...
- Jenkins安装过程
1.安装环境 配置java环境 安装Tomcat 2.将Jenkins.war 包放入Tomcat的webapps目录 3.启动tomcat后,tomcat会解压war包,生成一个jenkins文件夹 ...
- 1.5 GO json转Map
使用GO将show slave status查询返回的json串转为Map类型 package main import ( "encoding/json" "fmt&qu ...
- my17_Mysql 主从切换
注意事项: 从库提升为主库read_only要设置为OFF原主库改为从库后,read_only要设置ONread_only=ON并不能对root生效,确保root不会进行数据写入从主库进行 flush ...
- getter与setter
var obj = { get a() { return 2; }, get c() { return 34 } } Object.defineProperty( obj, 'b', { get: f ...
- ace+validate表单验证(两种方法)
//修改密码(直接在validate中验证提交) $("#changePassword").on(ace.click_event, function() { var html = ...
- PlayMaker Debug Int/Float/Vector3...
1.在一个游戏对象上建一个PlayMakerFSM,在状态机里新建几个不同类型的变量: 2.再新加几个Action: 3.运行,结果如下:
- python的面向对象的特性(继承、封装、多态)
创建自已对象就python非常核心的概念,事实上,python被称为面向对象语言,本章会介绍如何创建对象.以及面向对象的概念:继承.封装.多态. 多态: 可对不同类的对象使用同样的操作. 封装:对外部 ...
- [转]png图片压缩大小但是不改变透明部分
降低PNG图片存储大小方法,图片压缩方法,如何降低PNG图片存储大小?前提是分辨率和尺寸大小不变,图形的透明部分不变.请看如下办法,亲测可用. 1. 将PNG图片用PS打开. 2. 图像-模式-8位/ ...
- CentOS7 安装oracle 客户端
参考 http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 下载 oracle-instantclient11. ...