题意:

给出三个字符串,每个字符串长度相同,给出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. HTML5上传文件显示进度

    下面我们使用Html 5的新特性file api实现上传文件,并显示上传文件进度百分比.意图是这样的,当选择文件时,显示当前文件信息.这里我们是结合Asp.net MVC做为服务端,您也可以是其它的服 ...

  2. 洛谷P3602 Koishi Loves Segments 贪心

    正解:贪心 解题报告: 传送门! 首先在学习贪心的入门题的时候我们就知道,当x=1的时候,也就是每条线段不能相交的时候的做法——就按右端点排序然后能选就选,也就是会议安排问题,原因显然?就你选右端点更 ...

  3. 【PyQt5-Qt Designer】QDoubleSpinBox-小数微调框

    QDoubleSpinBox-小数微调框 总体说明 大部分的总体说明和QSpinBox的差不多(详见:<PyQt5:微调框1>),这里主要把有差别的地方谈一下(三点). QDoubleSp ...

  4. html简单网页1

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  5. springmvc拦截器实现用户登录权限验证

    实现用户登录权限验证 先看一下我的项目的目录,我是在intellij idea 上开发的 1.先创建一个User类 package cn.lzc.po; public class User { pri ...

  6. 【托业】【新东方全真模拟】01~02-----P5~6

    12.precisely precise precision preciseness 114. 116. favorable adj.赞同的; 称赞的; 有利的; 讨人喜欢的; favor n.好感; ...

  7. 【SQL】SQL Between用法

  8. MongoDB与关系型数据库 区别

    mysql  mongodb 表     table    Collection 字段  Colum   Fields 行 row Document Mongo中的一些概念 ------------- ...

  9. 如何将finecms链接URL中的list和show去掉

    finecms上手还算比较快吧,对seo关注的朋友会想着将它的url改造了,里面多了-list-和-show-,可以直接去掉,下面就随着ytkah一起来进行设置吧. 首先到后台的url规则,将列表和列 ...

  10. jenkins+maven+gitlab触发构建

    1.安装插件 安装gitlab插件 回到项目配置在“构建触发器”那里有一个Build when a change is pushed to GitLab. GitLab webhook选项复制选项里的 ...