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,每根电 ...
随机推荐
- management & Actuator
self define indicator https://docs.spring.io/spring-boot/docs/current/reference/html/production-read ...
- Reactive Extensions入门
https://www.cnblogs.com/yangecnu/archive/2012/11/03/Introducting_ReactiveExtensions.html 前面我写过7篇文章粗略 ...
- mysql 安装以及卸载 CentOS 7
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar 安装:mkdir ...
- Java日志组件1---Jdk自带Logger(java.util.logging.Logger)
最近在看日志的一些东西,发现利用JDK自带的log也可以简单的实现日志的输出,将日志写入文件的过程记录如下: 1.新建LogUtil.Java( 里面写了几个静态方法,为log设置等级.添加log控制 ...
- 安装NetCDF及HDF5
平台信息 Description: CentOS Linux release 7.6.1810 (Core) 安装步骤 下载NetCDF.HDF5.zlib.curl[使用wget命令即可] 解包:t ...
- oracle命令查看表结构及表索引
--查看oracle数据库的单个表结构 select dbms_metadata.get_ddl('TABLE','TABLE_NAME') from dual; 括号里面有两个参数,第一个参数是我们 ...
- 阿里云主机windows系统Apache启用浏览器缓存的方法
一群友使用卡卡网的网站速度诊断工具诊断网站速度时,发现有几个需要优化的地方,其中较为重要的是“启用浏览器缓存”.诊断结果显示,网站尚未启用浏览器缓存. 图一:浏览器缓存未启用 群友找我帮忙设置一下,据 ...
- Andrew Ng 的 Machine Learning 课程学习 (week3) Logistic Regression
这学期一直在跟进 Coursera上的 Machina Learning 公开课, 老师Andrew Ng是coursera的创始人之一,Machine Learning方面的大牛.这门课程对想要了解 ...
- Aspose.Words导出图片 表格 Interop.Word
先定义一个WORD 模板, 然后替换文本.域 ,定位开始表格 文本和段落 // Specify font formatting Aspose.Words.Font font = builder.Fon ...
- IDEA学习中的参考资料
下载安装破解:https://www.cnblogs.com/wang1024/p/7485758.html FIntelliJ-IDEA13基础教程: http://static.runoob.co ...