B. 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

这道题目的意思很好理解。
第一种情况,你要的字符串和报纸上的字符串有多少相同的,每个字母相同的个数累加起来再输出。
第二种情况,你要的字符串和报纸上的字符串有多少值相同,但大小写不同,将每个字母的情况累加起来再输出。 在样例里有这样的情况
ZZZzzz
ZZZZzz 答案是:5 1 也就是说,在你统计完第一种情况后,一样的字母需要你减去,然后才能去统计第二种情况。
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ctype.h>
#include <queue>
#define mem(a, b) memset((a), (b), (sizeof(a)))
using namespace std;
const int max_size = + ;
char str1[max_size];
char str2[max_size];
int cnt1[];
int cnt2[]; int main()
{
gets(str1);
gets(str2);
int len1 = strlen(str1);
int len2 = strlen(str2);
mem(cnt1, );
mem(cnt2, ); for(int i = ; i < len1; i++)
{
cnt1[str1[i] - 'A']++;
}
for(int i = ; i < len2; i++)
{
cnt2[str2[i] - 'A']++;
} int ans1, ans2;
ans1 = ans2 = ; for(int i = ; i < ; i++)
{
int ans = min(cnt1[i], cnt2[i]);
cnt1[i] -= ans;
cnt2[i] -= ans;
ans1 += ans;
} for(int i = ; i < ; i++)
{
int ans = min(cnt1[i], cnt2[i+'a'-'A']) + min(cnt2[i], cnt1[i+'a'-'A']);
ans2 += ans;
}
cout << ans1 << " " << ans2 << endl;
return ;
}

CodeForces 518B. Tanya and Postcard的更多相关文章

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

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

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

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

  3. 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 ...

  4. CF Tanya and Postcard

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

  5. CodeForces - 508D Tanya and Password(欧拉通路)

    Description While dad was at work, a little girl Tanya decided to play with dad characters. She has ...

  6. codeforces 659C Tanya and Toys

    题目链接:http://codeforces.com/problemset/problem/659/C 题意: n是已经有的数字,m是可用的最大数字和 要求选自己没有的数字,且这些数字的数字和不能超过 ...

  7. codeforces 659C . Tanya and Toys 二分

    题目链接 将给出的已经有了的排序, 在前面加上0, 后面加上1e9+1. 然后对相邻的两项判断. 如果相邻两项之间的数的和小于m, 那么全都选上, m减去相应的值. 如果大于m, 那么二分判断最多能选 ...

  8. codeforces 508D . Tanya and Password 欧拉通路

    题目链接 给你n个长度为3的子串, 这些子串是由一个长度为n+2的串分割得来的, 求原串, 如果给出的不合法, 输出-1. 一个欧拉通路的题, 将子串的前两个字符和后两个字符看成一个点, 比如acb, ...

  9. Codeforces Round #293 (Div. 2)

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

随机推荐

  1. 非对称加密算法——RSA

    RSA     这种算法1978年就出现了,它是第一个既能用于数据加密也能用于数字签名的算法.它易于理解和操作,也很流行.算法的名字以发明者的名字命名:Ron Rivest, AdiShamir 和L ...

  2. 谷歌地图地理解析和反解析geocode.geocoder详解

    地址解析就是将地址(如:贵州省贵阳市)转换为地理坐标(如经度:106.71,纬度:26.57)的过程. 地理反解析和上面的过程相反是将地理坐标(如纬度:26.57,经度:106.71)转换为地址(中国 ...

  3. 外景VR的应用

    留坑,续写. 最近在做外景的项目,被相关的帧率优化和灯光布置困扰的不要不要的.下面写下我是怎么优化帧率和对帧率的一些理解. 帧率,游戏的重要影响因素,会对玩家的手感以及视觉产生重大的影响,一般的游戏帧 ...

  4. GridView 动态添加绑定列和模板列

    动态添加绑定列很简单:例如: GridView1.DataSourceID = "SqlDataSource1"; BoundField bf1 = new BoundField( ...

  5. javascript操作referer

    Referrer的重要性 HTTP请求中有一个referer的报文头,用来指明当前流量的来源参考页.例如在www.sina.com.cn/sports/上点击一个链接到达cctv.com首页,那么就r ...

  6. 一个很全的VTK实例网址

    https://cmake.org/Wiki/VTK/Examples/Cxx#Visualization

  7. Go - 路径、目录名、包名、文件名

    先看一个示例: 1.目录结构 bin pkg src pk1 pk2 function1.go function2.go index.go 2.function1.go 文件内容: package p ...

  8. 进阶系列三【绝对干货】----Log4.Net的介绍

    一.介绍 当我们开发软件时,一般都会加入运行期的跟踪手段,以方便后续故障分析和Bug调试..net framework本身提供了一个System.Diagnostics.Trace类来实现流程跟踪功能 ...

  9. BZOJ4590——[Shoi2015]自动刷题机

    1.题意:题意很简洁吧,就不概括了 2.分析:我思考了半天,我猜答案满足单调...没敢写,看了题解去问Claris为啥单调,Claris一句话" 因为n越大明显不可能做更多题 ", ...

  10. Python验证码6位自动生成器

    Python验证码6位自动生成器