【Codeforces Round #482 (Div. 2) B】Treasure Hunt
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
我们考虑每个字符串中出现最多的字母出现的次数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的更多相关文章
- 【Codeforces Round #482 (Div. 2) C】Kuro and Walking Route
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把x..y这条路径上的点标记一下. 然后从x开始dfs,要求不能走到那些标记过的点上.记录节点个数为cnt1(包括x) 然后从y开始 ...
- Codeforces Round #482 (Div. 2) :B - Treasure Hunt
题目链接:http://codeforces.com/contest/979/problem/B 解题心得: 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必 ...
- Codeforces Round #482 (Div. 2) B、Treasure Hunt(模拟+贪心)979B
题目 大致题意 n表示要进行n次操作,接着给出三个字符串,表示三个人初始拥有的串.每次操作要替换字符串中的字母,询问最后在游戏中曾出现过的相同的子串谁最多. 思路 (1) 讨论最多的子串,肯定是全部 ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- Windows下通过FTP自动上传和下载动态文件名
某个项目中每天会生成一个以文件名+日期.rar文件,如bcpdata2012-08-31.rar文件,动态的部分为日期部分,在windows环境变量中用 %date:~0,10% 表示,这个文件生成后 ...
- 洛谷 1144 最短路计数 bfs
洛谷1144 最短路计数 传送门 其实这道题目的正解应该是spfa里面加一些处理,,然而,,然而,,既然它是无权图,,那么就直接bfs了,用一个cnt记录一下每一个点的方案数,分几种情况讨论一下转移, ...
- B - Networking
B - Networking 思路:并查集板子. #include<cstdio> #include<cstring> #include<iostream> #in ...
- Ajax-URL 防止数据缓存,添加时间戳
url:CONTEXTPATH + "/dataService/getSourceStatics?type=0&t="+new Date().getTime(),
- 又一次发现Oracle太美之glogin.sql
又一次发现Oracle太美之glogin.sql 刚開始接触Oracle的时候,有时候一登陆一个生产环境.常常会出现以下的情况: [oracle@rh64 app]$ sqlplus / as sys ...
- ios 导航栏 点击barbutton的按钮 下拉列表
环境:xocde5.0.2+ios7.0.1 1.导航栏 ----点击科目--------下拉列表 代码:NGRightTableViewViewController.h #import <UI ...
- iOS-UIApplication详解
UIApplication简介 UIApplication对象是应用程序的象征. 每一个应用程序都有自己的UIApplication对象,而且是单例. 一个iOS程序启动后创建的第一个对象就是UIAp ...
- iodine免费上网——本质就是利用dns tunnel建立tcp,然后tcp proxy来实现通过访问虚拟dns0网卡来访问你的dns 授权server
我的命令: server端: sudo iodined -P passwd -f -DD 10.0.0.100 abc.com client端(直连模式,-r表示使用xxx.abc.com的xxx来转 ...
- 【转】iOS多语言本地化(国际化)设置
原文网址:http://www.jianshu.com/p/2b7743ae9c90 讨论的iOS应用中的多语言设置,Ok 一般是两种情况: 1.根据当前设备语言自动切换显示 2.在应用中可进行语言设 ...
- python对象 -- 组合
详解组合:#Demo1class Game_kind: def __init__(self,nickname,sex,hp,ad): self.nickname = nickname self.sex ...