【Codeforces 979B】Treasure Hunt
【链接】 我是链接,点我呀:)
【题意】
每次你可以将一个字符变成一个不同于本身的字符.
每个人需要改变n次(且不能不改变)
设每个人的字符串中出现次数最多的字符出现的次数为cnt[0~2]
问你谁的cnt值最大
如果最大的两个cnt相同 输出draw
【题解】
模拟就好
注意这种情况(n=1)
1
aaa
aab
第一个人因为必须要改变一个,所以cnt最大为2
第二个人则为3
【代码】
import java.io.*;
import java.util.*;
public class Main {
static InputReader in;
static PrintWriter out;
public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
}
static int N = 50000;
static class Task{
int n;
String s[] = new String[3];
int ma[] = new int[3];
int cnt[][] = new int[3][500];
int len;
TreeMap dic = new TreeMap();
public void solve(InputReader in,PrintWriter out) {
n = in.nextInt();
for (int i = 0;i < 3;i++) s[i] = in.next();
for (int i = 0;i < 3;i++) {
for (int j = 0;j < (int)s[i].length();j++) {
cnt[i][(int)s[i].charAt(j)]++;
}
for (int j = 'a';j <= 'z';j++)
ma[i] = Math.max(ma[i], cnt[i][j]);
for (int j = 'A';j <='Z';j++)
ma[i] = Math.max(ma[i], cnt[i][j]);
if (ma[i]==(int)s[i].length()) {
if (n%2==1) {
ma[i]--;
}
}else {
ma[i] = Math.min(ma[i]+n, s[i].length());
}
}
String s[] = {"Kuro","Shiro","Katie"};
if(ma[0]>ma[1]) {
int x = ma[0];ma[0] = ma[1];ma[1] = x;
String t = s[0];s[0] = s[1];s[1] = t;
}
if(ma[1]>ma[2]) {
int x = ma[1];ma[1] = ma[2];ma[2] = x;
String t = s[1];s[1] = s[2];s[2] = t;
}
if(ma[0]>ma[1]) {
int x = ma[0];ma[0] = ma[1];ma[1] = x;
String t = s[0];s[0] = s[1];s[1] = t;
}
if (ma[1]==ma[2]) {
out.println("Draw");
}else {
out.println(s[2]);
}
}
}
static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer;
public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
}
public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
【Codeforces 979B】Treasure Hunt的更多相关文章
- 【codeforces 807B】T-Shirt Hunt
[题目链接]:http://codeforces.com/contest/807/problem/B [题意] 你在另外一场已经结束的比赛中有一个排名p; 然后你现在在进行另外一场比赛 然后你当前有一 ...
- 【树形dp】Treasure Hunt I
[ZOJ3626]Treasure Hunt I Time Limit: 2 Seconds Memory Limit: 65536 KB Akiba is a dangerous coun ...
- 【Codeforces 1027D】Mouse Hunt
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 先求出来强连通分量. 每个联通分量里面,显然在联通块的尽头(没有出度)放一个捕鼠夹就ok了 [代码] #include <bits/st ...
- 【Codeforces 494A】Treasure
[链接] 我是链接,点我呀:) [题意] 让你把"#"用至少一个右括号代替 使得整个括号序列合法 [题解] 首先我们不要考虑井号 考虑最简单的括号序列 并且把左括号看成1,右括号看 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 505C】Mr.Kitayuta,the Treasure Hunter
[题目链接]:http://codeforces.com/problemset/problem/505/C [题意] 一开始你跳一步长度为d; 之后你每步能跳d-1,d,d+1这3种步数; 然后在路上 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- E20170531-hm
passage n. 通路; 通道 discrete adj. 分离的,不相关联的; 分立式; 非连续; alternative 替代的; 另类的; 备选的; 其他的; intent ...
- [App Store Connect帮助]五、管理构建版本(2)查看构建版本和文件大小
您可以查看您为某个 App 上传的所有构建版本,和由 App Store 创建的变体版本的大小.一些构建版本在该 App 发布到 App Store 上后可能不会显示. 必要职能:“帐户持有人”职能. ...
- composer查看安装情况
composer install --no-progress --profile -vvv
- Linux 常规操作指南
1.修改Linux服务器别名 临时修改: vim /etc/hostname 修改别名 永久修改: vim /etc/sysconfig/network 添加 HOSTNAME=别名 重启服务器 ...
- 236 Lowest Common Ancestor of a Binary Tree 二叉树的最近公共祖先
给定一棵二叉树, 找到该树中两个指定节点的最近公共祖先. 详见:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tre ...
- [书目20140824]触动人心:设计优秀的iPhone应用
关于作者致谢译者序入门设计令人欣喜且易用的应用等下……先吸口气阅读本书不需要专业知识忠言一切从点击开始 我们是如何使用iPhone应用的行走中:一只手,一只眼睛,一直在抖动尽快搞定满满一箱 ...
- 26 c#类的组合
组合即将各个部分组合在一起.程序设计中就是用已有类的对象来产生新的类. 桌子由木板和钉子组合而成,台灯使用灯座,灯管,电线,接头等拼起来的.我们发现自己周围的很多东西都是由更小的其它东西拼凑构成的,就 ...
- leetcode377 Combination Sum IV
思路: dp. 实现: class Solution { public: int combinationSum4(vector<int>& nums, int target) { ...
- win7如何设置自动关机
如果想设置Win7按照自己意愿自动关机,而又不希望下载安装第三方软件,则可以通过以下两个方法来简单实现. 工具/原料 Windows7操作系统环境 方法1:利用cmd命令 1 打开cmd窗口. 方法一 ...
- Android ViewPager+HorizontalScrollView实现标题栏滑动(腾讯新闻)
1) ViewPager提供了左右滑动切换页面的方法,但是它所提供的标题只是无语,估计没有真正的项目会照搬拿过来;并且它只能一页一页滑,我想直接查看最后一页要滑半天; 2) 看了腾讯新闻客户端感觉体验 ...