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

【题意】

每次你可以将一个字符变成一个不同于本身的字符.
每个人需要改变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的更多相关文章

  1. 【codeforces 807B】T-Shirt Hunt

    [题目链接]:http://codeforces.com/contest/807/problem/B [题意] 你在另外一场已经结束的比赛中有一个排名p; 然后你现在在进行另外一场比赛 然后你当前有一 ...

  2. 【树形dp】Treasure Hunt I

    [ZOJ3626]Treasure Hunt I Time Limit: 2 Seconds      Memory Limit: 65536 KB Akiba is a dangerous coun ...

  3. 【Codeforces 1027D】Mouse Hunt

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 先求出来强连通分量. 每个联通分量里面,显然在联通块的尽头(没有出度)放一个捕鼠夹就ok了 [代码] #include <bits/st ...

  4. 【Codeforces 494A】Treasure

    [链接] 我是链接,点我呀:) [题意] 让你把"#"用至少一个右括号代替 使得整个括号序列合法 [题解] 首先我们不要考虑井号 考虑最简单的括号序列 并且把左括号看成1,右括号看 ...

  5. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  6. 【codeforces 505C】Mr.Kitayuta,the Treasure Hunter

    [题目链接]:http://codeforces.com/problemset/problem/505/C [题意] 一开始你跳一步长度为d; 之后你每步能跳d-1,d,d+1这3种步数; 然后在路上 ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. 【175】Easy CHM的使用

    首先下载软件,EasyCHM3.84完美破解版.rar! 安装好之后,打开程序,点击“新建”,然后浏览到存放 htm 文件的目录. 鼠标右键,选择“添加目录项”!如下图所示. 在弹出的文本框中,首先选 ...

  2. 【转载】Java - Wait & Notify

    [本文转自]http://www.cnblogs.com/dolphin0520/p/3920385.html 这三个方法的文字描述可以知道以下几点信息: 1)wait().notify()和noti ...

  3. bzoj 1026: [SCOI2009]windy数【数位dp】

    忘记limit不能记WA了一发-- 典型数位dp,变成work(r)-work(l-1),然后dfs的时候记录w当前位置,la上一个数选的什么,lm当前位是否有上限,ok当前位是否可以不考虑差大于等于 ...

  4. .net中RSA加密解密

    1.产生密钥: private static void CreateKey() { using (RSACryptoServiceProvider rsa = new RSACryptoService ...

  5. 287 Find the Duplicate Number 寻找重复数

    一个长度为 n + 1 的整形数组,其中的数字都在 1 到 n 之间,包括 1 和 n ,可知至少有一个重复的数字存在.假设只有一个数字重复,找出这个重复的数字.注意:    不能更改数组内容(假设数 ...

  6. sublime 3 最新注册码

    http://9iphp.com/web/html/sublime-text-3-license-key.html

  7. 第八届蓝桥杯省赛C/C++ A组第8题 包子凑数

    参考了http://blog.csdn.net/y1196645376/article/details/69718192 思路: 数论+完全背包. 实现: #include <iostream& ...

  8. WordPress百度熊掌号页面改造(纯代码实现)

    一.粉丝关注改造 1.添加熊掌号ID声明 ID声明 <script src="//msite.baidu.com/sdk/c.js?appid=你的熊掌ID">< ...

  9. Python之数据聚合与分组运算

    Python之数据聚合与分组运算 1. 关系型数据库方便对数据进行连接.过滤.转换和聚合. 2. Hadley Wickham创建了用于表示分组运算术语"split-apply-combin ...

  10. C#常见问题总结(三)

    11.sql比access好在哪里,为什么都用sql 解决方法: 数据量大,可以在服务器端,access一般在单机的时候用 12.c#基础视频教程有吗 解决方法: 零基础学C#这本书带全套C#基础视频 ...