【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

我们考虑每个字符串中出现最多的字母出现的次数cnt[3]
对于这3个cnt的值。
如果cnt+n但是如果cnt+n>s[i].size()

那就有问题了。

因为每次变换的字母不能和原来的一样。

因此全都变成某个字母之后。接下来肯定会破坏这个全都一样的性质。

所以我们可以这样。

贪心地全都变成这个出现次数最多的字母。

直到只剩下一个字母不为这个字母,也即"xxxaxxxx"中的a

然后我们设剩余轮数为cnt,那么我们再用cnt次操作把这个a一直变换,变成a,b,c,...然后在最后一次把它变成x

这样就能保证最大了。

但是有一种情况例外。

就是n1,然后cnt[i]s[i].size()

这种情况只能变换一次。

显然是变不回来的。

(也就是说全都是这个出现次数最多的字母

所以最大值是s[i].size()-1;

【代码】

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep1(i,a,b) for(int i=a;i>=b;i--)
#define rson rt<<1|1,m+1,r
#define lson rt<<1,l,m
using namespace std;
const int N=1e5+100;
int n,cnt[3],rest[3];
string s[3];
map<char,int> mmap[3]; struct abc{
string s;
int num;
}b[3]; bool cmp(abc a,abc b){
return a.num>b.num;
} int main()
{
ios::sync_with_stdio(false),cin.tie(0);
cin>>n;
rep(i,0,2) cin >> s[i];
rep(i,0,2){
rep(j,0,(int)s[i].size()-1){
mmap[i][s[i][j]]++;
cnt[i] = max(cnt[i],mmap[i][s[i][j]]);
}
} b[0].s = "Kuro";
b[1].s = "Shiro";
b[2].s = "Katie";
rep(i,0,2) {
if (cnt[i]+n>(int)s[i].size()){
if (cnt[i]==(int)s[i].size() && n==1) cnt[i] = (int)s[i].size()-1;
else cnt[i] = (int)s[i].size();
}else cnt[i] = cnt[i]+n;
b[i].num = cnt[i]; }
sort(b+0,b+0+3,cmp);
if (b[0].num==b[1].num){
cout<<"Draw"<<endl;
}else{
cout<<b[0].s<<endl;
}
return 0;
}

【Codeforces Round #482 (Div. 2) B】Treasure Hunt的更多相关文章

  1. 【Codeforces Round #482 (Div. 2) C】Kuro and Walking Route

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把x..y这条路径上的点标记一下. 然后从x开始dfs,要求不能走到那些标记过的点上.记录节点个数为cnt1(包括x) 然后从y开始 ...

  2. Codeforces Round #482 (Div. 2) :B - Treasure Hunt

    题目链接:http://codeforces.com/contest/979/problem/B 解题心得: 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必 ...

  3. Codeforces Round #482 (Div. 2) B、Treasure Hunt(模拟+贪心)979B

    题目 大致题意 n表示要进行n次操作,接着给出三个字符串,表示三个人初始拥有的串.每次操作要替换字符串中的字母,询问最后在游戏中曾出现过的相同的子串谁最多. 思路 (1)  讨论最多的子串,肯定是全部 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  6. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  7. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

随机推荐

  1. JavaScript(DOM编程补充一)

    HTML属性的直接调用: 还可以通过getAttribute方法获取属性的值: setAttribute方法: removeAttribute ---------------------------- ...

  2. Hibernate 一对多

    表与表之间关系回顾(重点) 1 一对多 (1)分类和商品关系,一个分类里面有多个商品,一个商品只能属于一个分类 (2)客户和联系人是一对多关系 - 客户:与公司有业务往来,百度.新浪.360 - 联系 ...

  3. HDU 4133

    注意题目中的一句话:If a number m has bigger evaluating value than all the numbers smaller than it... 这让我重新想过反 ...

  4. [HTML 5] aria-hidden

    You want to use aria-hidden to prevent screen reader to access some content should be hidden from us ...

  5. struts2提交多个对象带图片

    一:实体类 二:前台页面 三:Action处理

  6. Unreal Engine 4 C++ 为编辑器中Actor创建自己定义图标

    有时候我们创建场景的时候,特定的Actor我们想给它一个特定的图标,便于观察.比方这样: 实现起来也非常easy.须要编写C++代码: 我们创建一个Actor,叫AMyActor.它包括一个Sprit ...

  7. tensorflow利用预训练模型进行目标检测(一):安装tensorflow detection api

    一.tensorflow安装 首先系统中已经安装了两个版本的tensorflow,一个是通过keras安装的, 一个是按照官网教程https://www.tensorflow.org/install/ ...

  8. 【HNOI 2004】宠物收养所

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1208 [算法] 建两棵平衡树维护领养者和宠物的特点值,这两棵平衡树支持 插入删除,查 ...

  9. WEEX SDK集成到工程(Integrate to Android) #25

    WEEX SDK集成到工程(Integrate to Android) #25 https://github.com/weexteam/article/issues/25

  10. Ubuntu16.04系统安装搜狗输入法

    前言:正常双击.deb软件包安装搜狗输入法会有bug,需要按照下面操作进行消除错误. 一.下载搜狗输入法Linux版软件包 下载地址为:http://pinyin.sogou.com/linux/ , ...