Tanya and Postcard
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string s. The newspaper contains string t, consisting of uppercase and lowercase English letters. We know that the length of string t greater or equal to the length of the string s.

The newspaper may possibly have too few of some letters needed to make the text and too many of some other letters. That's why Tanya wants to cut some n letters out of the newspaper and make a message of length exactly n, so that it looked as much as possible like s. 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".

Tanya wants to make such message that lets her shout "YAY!" as much as possible. If there are multiple ways to do this, then her second priority is to maximize the number of times she says "WHOOPS". Your task is to help Tanya make the message.

Input

The first line contains line s (1 ≤ |s| ≤ 2·105), consisting of uppercase and lowercase English letters — the text of Tanya's message.

The second line contains line t (|s| ≤ |t| ≤ 2·105), consisting of uppercase and lowercase English letters — the text written in the newspaper.

Here |a| means the length of the string a.

Output

Print two integers separated by a space:

  • the first number is the number of times Tanya shouts "YAY!" while making the message,
  • the second number is the number of times Tanya says "WHOOPS" while making the message.
Sample test(s)
input
AbC
DCbA
output
3 0
input
ABC
abc
output
0 3
input
abacaba
AbaCaBA
output
3 4

题目太难懂,三个人读出三种意思。

 #include <iostream>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std; int T_L_HAVE[] = {};
int S_L_HAVE[] = {};
int T_U_HAVE[] = {};
int S_U_HAVE[] = {}; int main(void)
{
string s;
string t;
int len_s,len_t;
int sum_yay = ;
int sum_whoops = ; cin >> s >> t;
len_s = s.size();
len_t = t.size(); for(int i = ;i < len_t;i ++)
if(islower(t[i]))
T_L_HAVE[t[i] - 'a'] ++;
else
T_U_HAVE[t[i] - 'A'] ++; for(int i = ;i < len_s;i ++)
if(islower(s[i]))
S_L_HAVE[s[i] - 'a'] ++;
else
S_U_HAVE[s[i] - 'A'] ++; for(int i = ;i < len_s;i ++)
{
if(islower(s[i]) && T_L_HAVE[s[i] - 'a'])
{
S_L_HAVE[s[i] - 'a'] --;
T_L_HAVE[s[i] - 'a'] --;
sum_yay ++;
}
else if(isupper(s[i]) && T_U_HAVE[s[i] - 'A'])
{
S_U_HAVE[s[i] - 'A'] --;
T_U_HAVE[s[i] - 'A'] --;
sum_yay ++;
}
} for(int i = ;i < len_s;i ++)
{
if(islower(s[i]) && S_L_HAVE[s[i] - 'a'] && T_U_HAVE[s[i] - - 'A'])
{
S_L_HAVE[s[i] - 'a'] --;
T_U_HAVE[s[i] - - 'A'] --;
sum_whoops ++;
}
else if(isupper(s[i]) && S_U_HAVE[s[i] - 'A'] && T_L_HAVE[s[i] + - 'a'])
{
S_U_HAVE[s[i] - 'A'] --;
T_L_HAVE[s[i] + - 'a'] --;
sum_whoops ++;
}
} cout << sum_yay << ' ' << sum_whoops << endl; return ;
}

CF 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 Round #293 (Div. 2) B. Tanya and Postcard 水题

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

  3. codeforces 518B. Tanya and Postcard 解题报告

    题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...

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

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

  5. Codeforces Round #293 (Div. 2)

    A. Vitaly and Strings 题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串 字符转处理:字典序排序 很巧妙的方法,因为s < t,只要找比t字典 ...

  6. codeforces518B

    Tanya and Postcard CodeForces - 518B 有个小女孩决定给他的爸爸寄明信片.她已经想好了一句话(即长度为n的字符串s),包括大写和小写英文字母.但是他不会写字,所以她决 ...

  7. CF 1005A Tanya and Stairways 【STL】

    Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairw ...

  8. CF 584B Kolya and Tanya

    题目大意:3n个人围着一张桌子,给每个人发钱,可以使1块.2块.3块,第i个人的金额为Ai.若存在第个人使得Ai + Ai+n + Ai+2n != 6,则该分配方案满足条件,求所有的满足条件的方案数 ...

  9. CF 508D Tanya and Password(无向图+输出欧拉路)

    ( ̄▽ ̄)" //不知道为什么,用scanf输入char数组的话,字符获取失效 //于是改用cin>>string,就可以了 //这题字符的处理比较麻烦,输入之后转成数字,用到函 ...

随机推荐

  1. hello, angular

    开始系统学习一下angular!首先是hello world.根据官网给出的例子,我们一下做出下面这个东西: <!DOCTYPE html> <html ng-app> < ...

  2. Delphi实例-IdTCPServer和IdTCPClient的使用(支持文件发送)

    相关资料: http://blog.csdn.net/earbao/article/details/46514313 结果注意: 1.Use IdContext.IdGlobal 这两个单元2.不能使 ...

  3. [iOS基础控件 - 6.12.4] NavigationController vs TabBarController

    A.属性 1. Item NavigationController: navigationItem (不需要创建) title rightBarButtonItems/ rightBarButtonI ...

  4. ajax 源生,jquery封装 例子 相同哈哈

    http://hi.baidu.com/7636553/item/bbcf5fc93c8c950aac092f22 ajax使用回调函数的例子(原生代码和jquery代码) 一. ajax代码存在的问 ...

  5. 学习微软中间语言(MSIL)的绝佳工具 Dotnet IL Editor 推荐

    Dotnet IL Editor是一款.NET平台反编译工具,可以反编译.NET程序集文件为IL代码,并且可以执行,调试反编译后生成的IL代码.它的设计出发点比较直观,新建一个项目,添加程序集文件,设 ...

  6. Java Thread Basic

    一.Java的多线程有三种实现方式. 1.继承创建. a.定义子类,重写run方法 b.创建Thread子类的实例(即现成对象) c.调用start() 方法启动现成 特征:不可以共享变量. publ ...

  7. OpenNebula Restfull 接口请求示例

    Fri Jun 20 07:28:20 2014 [I]: 10.0.2.2 - - [20/Jun/2014 07:28:20] "POST /vmtemplate HTTP/1.1&qu ...

  8. window.open()打开窗口的几种方式

    1. window.open("http://www.baidu.com/", "_search");//在一个新的窗口打开百度,并且使URL地址出现在搜索栏中 ...

  9. 用Emacs 写python了

    之前都是用python 自带的IDLE 写 python 的,现在换了Emacs,感觉真是不错,爽. 截图留念: 用了sr-speedbar ,顿时有了IDE 的感觉,是不是很爽. 版权声明:本文为博 ...

  10. 【VxWorks系列】任务间同步与通信之共享内存

    在开始之前先说明三个概念,任务间的同步,互斥,通信. 同步,是指一个任务等待某个条件发生,而另外一个任务引发这个条件后,等待的任务会被触发执行相应的处理.这就是一个任务与另一任务之间的同步控制. 互斥 ...