题意:

给出三个字符串,每个字符串长度相同,给出n,要求在n轮内,每一个字符串必须改变一个字符。

问最后哪个字符串中拥有最多相同的字符,即美丽度最大。

思路:

首先,很不容易想到的一点是从a变到a,有两种方式a -> 其它 -> a,或者a -> 其它 -> 其它 -> a,即变2次或者变3次。

变3次是有意义的,比如第86个样例(wa在第86):

3

aaaaa

aaaaa

aaaab

答案是draw

因为第一个选一个a变3次变回a,第二个同理,第三个b到a再到b再到a就可以了,所以可以相同,这里存在一个误区。

根据这一组数据发现,唯一可能变少的情况就是这个字符串全部字母相同并且n = 1,那么最后的美丽度要减一,比如aaaaa,只能变一个,所以美丽度减一。

其它情况按照普通情况处理就好了。

相加大于len的直接取为len就ok。

代码:

 #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
const int N = 1e5 + ;
char a[N],b[N],c[N];
map<char,long long> as,bs,cs;
int main()
{
long long n;
scanf("%lld",&n);
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
int len = strlen(a);
for (int i = ;i < len;i++)
{
as[a[i]]++;
}
for (int i = ;i < len;i++)
{
bs[b[i]]++;
}
for (int i = ;i < len;i++)
{
cs[c[i]]++;
}
long long aa = ,bb = ,cc = ;
if (as.size() == && n == )
{
aa = len - ;
}
else
{
for (auto it = as.begin();it != as.end();++it)
{
aa = max(aa,it -> second + n);
}
if (aa > len) aa = len;
}
if (bs.size() == && n == )
{
bb = len - ;
}
else
{
for (auto it = bs.begin();it != bs.end();++it)
{
bb = max(bb,it -> second + n);
}
if (bb > len) bb = len;
}
if (cs.size() == && n == )
{
cc = len - ;
}
else
{
for (auto it = cs.begin();it != cs.end();++it)
{
cc = max(cc,it -> second + n);
}
if (cc > len) cc = len;
}
long long ans = max(aa,bb);
ans = max(ans,cc);
int cnt = ;
int ma = -;
if (aa == ans)
{
cnt++;
ma = ;
}
if (bb == ans)
{
cnt++;
ma = ;
}
if (cc == ans)
{
cnt++;
ma = ;
}
//printf("%d*\n",ma);
if (cnt >= ) puts("Draw");
else
{
if (ma == ) puts("Kuro");
if (ma == ) puts("Shiro");
if (ma == ) puts("Katie");
}
return ;
}

codeforces 979B Treasure Hunt的更多相关文章

  1. Treasure Hunt CodeForces - 979B

    After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up wit ...

  2. A. Treasure Hunt Codeforces 线性代数

    A. Treasure Hunt time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. Treasure Hunt

    Treasure Hunt time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. zoj Treasure Hunt IV

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  5. POJ 1066 Treasure Hunt(线段相交判断)

    Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4797   Accepted: 1998 Des ...

  6. ZOJ3629 Treasure Hunt IV(找到规律,按公式)

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  7. POJ 1066 Treasure Hunt(相交线段&amp;&amp;更改)

    Treasure Hunt 大意:在一个矩形区域内.有n条线段,线段的端点是在矩形边上的,有一个特殊点,问从这个点到矩形边的最少经过的线段条数最少的书目,穿越仅仅能在中点穿越. 思路:须要巧妙的转换一 ...

  8. poj1066 Treasure Hunt【计算几何】

    Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8192   Accepted: 3376 Des ...

  9. zoj 3629 Treasure Hunt IV 打表找规律

    H - Treasure Hunt IV Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu ...

随机推荐

  1. cestOs 7安装Jenkins

    首先到https://jenkins.io/download/下载Jenkins的war包,放在tomcat下.启动tomcat. 打开对应url.后要求输入密码. 在服务器vim .jenkins/ ...

  2. 浏览器的兼容性(CSS浏览器兼容性、CSS hack)

    一.关于CSS hack(尽量不用或者少用,减少页面复杂度) 1.条件注释法:(我的测试是IE9及其以下才有效) 这种方式是IE浏览器专有的Hack方式,微软官方推荐使用的hack方式.举例如下 只在 ...

  3. webpack导入css及各项loader

    1. webpack导入css 1) 下载相关的加载器 npm install style-loader css-loader -D 2)将index.css引入到mian.js中 import '. ...

  4. wget 下载命令

    //下载单个文件 wget http://116.199.2.206:81/2Q2WADC9FB8D469200FF61C643601888142263926D08_unknown_65A3E1A23 ...

  5. Jmeter原理

    Jmeter结构体系及运行原理   Jmeter结构体系 把Jmeter的结构体系拆分为三维空间,如图: X1~X5:是负载模拟的一个过程,使用这些组件来完成负载的模拟: X1:选择协议,模拟用户请求 ...

  6. 封装||property

    封装 封装:主要是指在类的定义阶段将,以__开头的属性名进行变形..例如:__name ==> _People__name 封装的主要特点: 1.在类外部无法直接__name,想要在外部调用可以 ...

  7. IconMoon图标字体制作

    官网:https://icomoon.io/ 点击右上角“IconMoon APP” 点击左上角“import Icons”按钮 选中小图标 - 选择右下角“Generate Font”生成图标字体 ...

  8. 新发现:排序算法时间复杂度只有O(3n),命名为"wgw"排序法

    思路:首先在待排序数组i[]中找出最大的值,以(最大值+1)的大小创建一个空数组kk[],然后遍历待排序数组i[]中的值n,其值n对应数组kk[]中的第n个元素加1.最后再把数组kk[]排好序的值赋回 ...

  9. 采用Extjs MVVM + ThinkPHP 架构开发的思考

    前后台号称都是MVC模式, 后台ThinkPHP框架实际上只提供web操作接口,直接返回json数据,因此只能算有Model和Controller两层, 前台ExtjsMVVM模式实际上就是分模块后的 ...

  10. Centos7系统防火墙上开端口

    //permanent 永久生效 没有此参数重启失效 firewall -cmd --zone=public --add -port=80/tcp --permanent            //开 ...