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. nginx虚拟主机配置小结

    nginx的安装在lnmp环境搭建中已经介绍过了,配置文件在安装目录下的conf子目录下,主要主要分成四部分:main(全局设置).server(主机设置).upstream(负载均衡服务器设置).l ...

  2. 第二轮冲刺-Runner站立会议07

    今天:实现日历界面 明天:优化日历界面

  3. thinkphp自定义标签库

    thinkphp ~ php中 的类, 的成员变量, 本身是没有类型说明的, 那么我怎么知道它的类型呢? 或初始值呢? 通常在类定义中, 如果能给一个初始值的(对于已知简单类型的),最好给一个初始值, ...

  4. Android中finish掉其它的Activity

    在Android开发时,一般情况下我们如果需要关掉当前Activity非常容易,只需要一行代码 this.finish;即可.那么,如果是想要在当前Activity中关掉其它的Activity应该怎么 ...

  5. Floyed判环/龟兔算法

    求[(5+2√6)2^x+1 ] mod p 的值,其中 0 ≤ x < 232 , p 是个质数,p ≤ 46337 .(这里介绍的是一种暴力的做法) (5+2√6)2^n+1 = an + ...

  6. win7使用自带资源管理器来登陆FTP

    使用windows自带的资源管理器登陆FTP,其实很简单,打开计算机,在地址栏直接输入ftp://ftp.hostname即可. 但是这种方式需要每次输入ip地址,还要输入用户名和密码,比较麻烦.可能 ...

  7. 【转】Java读取matlab的.mat数据文件

    参考:Java读取mat文件 下载链接:ujmp  jmatio 下载完两个.jar文件之后,如何引用到java项目当中?项目名称->右键->Property->Java Build ...

  8. Android错误

    1. [2016-09-16 14:25:45 - X_Card] Found 2 versions of android-support-v4.jar in the dependency list, ...

  9. 【目录】Leetcode

    Leetcode 1.动态规划 Palindrome Partitioning II(hard) ☆ Distinct Subsequences(hard) Edit Distance (hard) ...

  10. Java GridBagLayout 简单使用

    这里只介绍了很基础布局构建及使用,主要是关于 GridBagLayout. 首先整套流程大概是, 声明一个 GridBagLayout 对象 private GridBagLayout gridBag ...