题目链接: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. Lnmp的安装、配置

    一.首先在本地安装好虚拟机,在虚拟机上安装centos6.5,由于习惯问题,不喜欢直接在虚拟机上操作linux系统,习惯了ssh过去,直接用xshell操作,这完全是个人习惯问题: 1.  用xshe ...

  2. Memcached目录

    Memcached 简介.安装和基本使用 Memcached基础知识 理解Memcached的分布式 Memcached存储命令 - set Memcached存储命令 - add Memcached ...

  3. ExtJS请求验证方法

    //登录连接数据库验证 function loginCheck() { var UserName = Ext.getCmp("UserName").getValue(); var ...

  4. Myeclipse如何关联源码

    Myeclipse版本:Myeclipse2014 关联源码前要下载对应的源码,如本例的dom4j-1.6.1.jar,则去下载对应的源码dom4j-1.6.1.zip 如果做的是web项目,就要将该 ...

  5. seajs的那点事(很坑的事),和本白的一点事(更坑的事)

    在开始之前,偶先吐槽加逗比一下,2天前,CCAV的本白和百度的菊花成功潜入到了携程大楼 然后在没有找到他们运维的情况下,四处乱逛,企图把他们的服务器给root一下,然后再瞎逛之后到了一个很神奇的地方 ...

  6. Todd's Matlab讲义第6讲:割线法

    割线法 割线法求解方程\(f(x)=0\)的根需要两个接近真实根\(x^\*\)的初值\(x_0\)和\(x_1\),于是得到函数\(f(x)\)上两个点\((x_0,y_0=f(x_0))\)和\( ...

  7. Ruby基本语法规则

    1.Ruby常用数据类型 Numbers, Strings, Booleans my_num = 25 my_boollean = true (or false) my_string = " ...

  8. 被拒原因——You have selected the Kids Category for your app, but it does not include the required privacy policy. Please update your app metadata to include a privacy policy URL and ensure that the URL yo

    对于一些孩子类的应用,必须加上隐私政策网址(URL),直接截个图吧! 就是你上架的时候,填写应用信息,里面有一个隐私政策网址(URL),望后者不掉坑里了!!!

  9. qstring与char*、基本数据类型的转换

    1.qstring转化为char* QString.toStdString.c_str() 2.char*转化为QString str = QString(QLatin1String(mm)); 3. ...

  10. windows 下wamp环境3 安装php7

    打开 http://php.net 点击download,选择Windows downloads,根据系统选择版本 注意左侧的提示: With Apache you have to use the T ...