题目链接:http://codeforces.com/problemset/problem/518/B

题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就将 s 这个数量加到 YAY! 的答案里,少于的话就加 t 中有的数量;如果 t 中有跟 s 相同的字母但是大小写不对应(例如A-a,z-Z),就加到 WHOOPS 的答案里。

  举个例子就很容易明白了。例如 s 和 t 分别为:

ncMeXssLHS
uwyeMcaFatpInZVdEYpwJQSnVxLK

 字符s、n、c、M、e、L、S 两者都有,于是 ans_YAY = 6;XssH中 X 在字符串 t 中 有小写字母x,其他的ssH 在字符串 t 中根本就没有!

其实...........做virtual 的时候没有看懂题目 = =!是直接看测试数据看出来的。

If the letter in some position has correct value and correct letter case (in the string s and in the string that Tanya will make), then she shouts joyfully "YAY!", and if the letter in the given position has only the correct value but it is in the wrong case, then the girl says "WHOOPS".

  这句话不仅内有乾坤,还意味深长呢~~~~~看懂题目是很重要滴!

 

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = 2e5 + ;
const int maxl = ;
char s[maxn], t[maxn];
int cs[maxl], ct[maxl]; inline int get_id(char ch)
{
if (ch >= 'a' && ch <= 'z')
return ch - 'a';
return ch-'A' + ; // 大写字母从下标26开始
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE while (scanf("%s%s", s, t) != EOF) {
memset(cs, , sizeof(cs));
int ls = strlen(s), lt = strlen(t);
for (int i = ; i < ls; i++)
cs[get_id(s[i])]++;
memset(ct, , sizeof(ct));
for (int i = ; i < lt; i++)
ct[get_id(t[i])]++; int ans_YAY = ;
for (int i = ; i < maxl; i++) {
int minuend = min(cs[i], ct[i]);
cs[i] -= minuend, ct[i] -= minuend;
ans_YAY += minuend;
}
int ans_WHOOPS = ;
for (int i = ; i < ; i++) {
int added = min(cs[i], ct[i+]) + min(cs[i+], ct[i]);
ans_WHOOPS += added;
}
printf("%d %d\n", ans_YAY, ans_WHOOPS);
}
return ;
}

codeforces 518B. Tanya and Postcard 解题报告的更多相关文章

  1. CodeForces 518B. Tanya and Postcard

    B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. CodeForces 518B Tanya and Postcard (题意,水题)

    题意:给定两个字符串,然后从第二个中找和第一个相同的,如果大小写相同,那么就是YAY,如果大小写不同,那就是WHOOPS.YAY要尽量多,其次WHOOPS也要尽量多. 析:这个题并不难,难在读题懂题意 ...

  3. Codeforces Educational Round 92 赛后解题报告(A-G)

    Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...

  4. codeforces 476C.Dreamoon and Sums 解题报告

    题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...

  5. Codeforces Round #382 (Div. 2) 解题报告

    CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...

  6. codeforces 507B. Amr and Pins 解题报告

    题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...

  7. codeforces 500B.New Year Permutation 解题报告

    题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...

  8. codeforces B. Xenia and Ringroad 解题报告

    题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...

  9. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

随机推荐

  1. jQuery 学习之路(4):事件

    一.文档载入事件 二.事件绑定 三.事件对象 四.浏览器事件 五.表单事件 六.键盘事件 七.鼠标事件

  2. Java 中浮点数---------BigDecimal和double(初探)

    为什么要使用 bigdecimal? 借用<Effactive Java>这本书中的话,float和double类型的主要设计目标是为了科学计算和工程计算.他们执行二进制浮点运算,这是为了 ...

  3. PHP基础OOP(一)

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  4. 定时任务-在spring中配置quartz

    使用的版本Spring4.04+Quartz2.2.3,关于jar包自行下载. 详细需要以下几个步骤来完成: 1.  定义要执行的Job类 2.  定义quartz的配置文件applicationCo ...

  5. JS/HTML 保存图片到本地:HTML <a> download 属性

    JS如何保存图片到本地呢?自己百度一下吧! 这里想要说的是,可以利用 HTML 的 <a> 标签 来是实现保存图片到本地的功能,参考代码如下: <a href="http: ...

  6. CentOS 6.5 zabbix 3.0.4 监控MySQL性能

    安装mysql [root@test3 /]# yum -y install mysql mysql-server 初始化数据库 [root@test3 /]# /etc/init.d/mysqld ...

  7. 两款基于Jquery的图表插件

    一.EasyPieChart 页面加载时,运行initPieChart()函数,调用easyPieChart()函数,显示出图表. 代码: var initPieChart = function() ...

  8. linux中tar命令用法

    把常用的tar解压命令总结下,当作备忘: tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其 ...

  9. auto与decltype

    今天搜狗笔试的一道选择题,原题给忘了,但记得所考的知识点.知识点很基础,但很容易忽视. 具体内容可参考C++ Primer. auto :变量取auto后,其所对应的类型        auto一般会 ...

  10. PictureCutting图片批量裁切(裁剪)工具

    PictureCutting图片批量裁切(裁剪)工具 写这个工具的原因是因为在获取一个软件的皮肤包中的图片的时候需要进行批量的裁切工作,而有没有找到在linux下简单好用的工具,干脆就用QT写了一个. ...