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. oracle 字符集转换:AL32UTF8->ZHS16GBK

    select userenv('language') from dual; --修改Oracle数据库字符集为ZHS16GBK : SQL>conn / as sysdba; SQL>sh ...

  2. 几个代码片段-计算程序运行时间+获得当前目录+生成MD5

    计算程序运行时间 long startTime = System.currentTimeMillis(); System.out.println("程序运行时间: " + (Sys ...

  3. Windows Server 2003 R2 64位简体中文版下载

    32位版 CD1: SHA1值:d0dd2782e9387328ebfa45d8804b6850acabf520 ed2k://|file|cn_win_srv_2003_r2_enterprise_ ...

  4. LINUX下成功搭建SVN

    步骤如下: 1: yum install -y subversion 2:svnserve –version 3: [root@singledb ~]# mkdir /u02/svn [root@si ...

  5. 斯特灵数 (Stirling数)

    @维基百科 在组合数学,Stirling数可指两类数,都是由18世纪数学家James Stirling提出的. 第一类 s(4,2)=11 第一类Stirling数是有正负的,其绝对值是个元素的项目分 ...

  6. 从Jetty、Tomcat和Mina中提炼NIO构架网络服务器的经典模式(三)

    转载 http://blog.csdn.net/cutesource/article/details/6192163 最后我们再看看NIO方面最著名的框架Mina,抛开Mina有关session和处理 ...

  7. dao 获取表最大排序实现

    public Long getMaxOrder(Long parentId) { Query query = this.getSession().createSQLQuery( "selec ...

  8. Long与long的比较

    Java中如果使用 == 双等于比较对象,等于比较的是两个对象的内存地址,也就是比较两个对象是否是同一个对象如果比较两个Long对象值是否相等,则不可以使用双等号进行比较,可以采用如下方式:1. 使用 ...

  9. ID生成器详解

    概述 ID 生成器也叫发号器,它的主要目的就是"为一个分布式系统的数据object产生一个唯一的标识",但其实在一个真实的系统里可能也可以承担更多的作用.概括起来主要有以下几点: ...

  10. JqueryMobile- 搭建主模板

    最近公司要开发手机端的,可是我没学过安卓,然后用HTML5+JQUERYMOBILE也可以做这些手机端的程序,做成个网页,发到网上,免强也行,于是开始了我JQUERYMOBILE的学习. 先放一下主模 ...