Codeforces Round #482 (Div. 2) :B - Treasure Hunt
题目链接:http://codeforces.com/contest/979/problem/B
解题心得:
- 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必须改变自己字符串中的一个字母,最后得分就是字符串中出现字符最多的字母的次数。
- 感觉这个题从题目描述到做法都像一个脑筋急转弯。主要明白一点,如果一个数要变回自己要怎么变。自己->其他->自己。自己->其他->其他->自己,推几个特例很容易就出来了。
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+;
struct Person{
string name;
int Max;
vector <int> ve;
}p[]; int change_times,len;
void init() {
map <char, int> maps;
for(int i='a', j='A';i<='z'&&j<='Z';i++,j++) {
maps[i] = ;
maps[j] = ;
}
char ri[maxn];
p[].name = "Kuro";
p[].name = "Shiro";
p[].name = "Katie";
scanf("%d",&change_times);
map <char, int> :: iterator iter;
for(int i=;i<;i++) {
maps.clear();
scanf("%s",ri);
len = strlen(ri);
for(int j=;j<len;j++)
maps[ri[j]]++;
for(iter=maps.begin();iter!=maps.end();iter++){
p[i].ve.push_back(iter->second);
}
for(int k='a', j='A';k<='z'&&j<='Z';k++,j++) {
if(maps[k] == || maps[j] == )
p[i].ve.push_back();
}
}
} bool cmp(Person a, Person b) {
return a.Max > b.Max;
} void solve() {
for(int i=;i<;i++) {
for(int j=;j<p[i].ve.size();j++) {
int k = p[i].ve[j];
if(k == len && change_times == ) {
p[i].Max = len -;
break;
}
int ch = len - k;
if(change_times < ch) {
p[i].Max = max(p[i].Max, k+change_times);
} else {
p[i].Max = len;
}
}
}
sort(p, p+, cmp);
if(p[].Max == p[].Max)
printf("Draw");
else
cout<<p[].name<<endl;
} int main() {
init();
solve();
return ;
}
Codeforces Round #482 (Div. 2) :B - Treasure Hunt的更多相关文章
- Codeforces Round #482 (Div. 2) B、Treasure Hunt(模拟+贪心)979B
题目 大致题意 n表示要进行n次操作,接着给出三个字符串,表示三个人初始拥有的串.每次操作要替换字符串中的字母,询问最后在游戏中曾出现过的相同的子串谁最多. 思路 (1) 讨论最多的子串,肯定是全部 ...
- 【Codeforces Round #482 (Div. 2) B】Treasure Hunt
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 我们考虑每个字符串中出现最多的字母出现的次数cnt[3] 对于这3个cnt的值. 如果cnt+n<=s[i].size 那么显 ...
- Codeforces Round #482 (Div. 2) : Kuro and GCD and XOR and SUM (寻找最大异或值)
题目链接:http://codeforces.com/contest/979/problem/D 参考大神博客:https://www.cnblogs.com/kickit/p/9046953.htm ...
- Codeforces Round #482 (Div. 2) :C - Kuro and Walking Route
题目连接:http://codeforces.com/contest/979/problem/C 解题心得: 题意就是给你n个点,在点集中间有n-1条边(无重边),在行走的时候不能从x点走到y点,问你 ...
- Codeforces Round #482 (Div. 2) B题
题目链接:http://codeforces.com/contest/979/problem/B B. Treasure Hunt time limit per test1 second memory ...
- 【枚举】【贪心】Codeforces Round #482 (Div. 2) B. Treasure Hunt
题意:给你3个字符串,3个人各对自己的字符串执行n轮操作,每一次选择一个字符变为任意一个和原来不同的字符.最后问你谁能使自己的串中的任意重复子串出现的次数最大化. 显然只需关注字符而非子串. 枚举每个 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
- Codeforces Round #511 (Div. 2):C. Enlarge GCD(数学)
C. Enlarge GCD 题目链接:https://codeforces.com/contest/1047/problem/C 题意: 给出n个数,然后你可以移除一些数.现在要求你移除最少的数,让 ...
- Codeforces Round #514 (Div. 2):D. Nature Reserve(二分+数学)
D. Nature Reserve 题目链接:https://codeforces.com/contest/1059/problem/D 题意: 在二维坐标平面上给出n个数的点,现在要求一个圆,能够容 ...
随机推荐
- February 9 2017 Week 6 Thursday
Happy life lies in a peaceful mind. 幸福的生活存在于心绪的宁静当中. What can be seen as happy life? Maybe the answe ...
- 如果把PNG、JPG、BMP和GIF文件批量转换为ICO文件?
有时候需要将大量的图片文件(比如PNG.JPG.BMP和GIF文件)批量转换为ICO图标文件,如果一个一个操作,非常费时间.本文将介绍如何用Dr. Folder软件快速批量转换图片文件为ICO图标文件 ...
- webpack学习(五)配置详解
配置详解 //使用插件html-webpack-plugin打包合并html //使用插件extract-text-webpack-plugin打包独立的css //使用UglifyJsPlugin压 ...
- Java虚拟机1:开篇
1.前言 由于后期学习需要用到大量的JVM底层的东西,所有本人调整了一下学习计划,打算先从JVM入手,了解整个JAVA的运行机制,内存模型,编译原理等等一些底层的东西,这样在学习 后面的东西,会有一种 ...
- Thread Costs
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/CreatingTh ...
- hdu 3068 最长回文_Manacher模板
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/neng18/article/details/24269469 pid=3068" rel= ...
- 常用的css选择器
1.最基本的 * * 选择所有元素. #id #firstname 选择 id="firstname" 的元素. .class .intro 选择 class="intr ...
- win7 xampp php7 yii2 配置sqlserver
第一步: https://www.microsoft.com/en-us/download/details.aspx?id=20098 下载 如下图 php7 版本 放到 xampp\php ...
- 【题解】洛谷P2661 [NOIP2015TG] 信息传递
题目来源:洛谷P2661 思路 运用并查集查找图中最小环的长度 如果A传递信息给B 就从A加一条边指向B 并更新A的父节点 从A到父节点的路径长度为B到父节点的路径长度+1 如果有两个点的祖先相同而且 ...
- Flex布局(一)flex-direction
采用Flex布局的元素,被称为Flex容器(flex container),简称"容器".其所有子元素自动成为容器成员,成为Flex项目(Flex item),简称"项目 ...