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

题意:给你两个串,s和t,如果s中的字符在t中出现过,那么yay++,如果仅仅是大小写不一样的话,那么就w++

找到了,就把那个字符删除掉

解法:优先满足yay,其次再满足w

然后直接跑一发就是了

int l[];
int u[];
string s,t;
int main()
{
cin>>s>>t;
for(int i=;i<t.size();i++)
{
if('a'<=t[i]&&t[i]<='z')
l[t[i]-'a']++;
else
u[t[i]-'A']++;
}
int a=,b=;
for(int i=;i<s.size();i++)
{
if(s[i]=='.')
continue;
if('a'<=s[i]&&s[i]<='z')
{
if(l[s[i]-'a']>)
{
a++;
l[s[i]-'a']--;
s[i]='.';
}
}
else
{
if(u[s[i]-'A']>)
{
a++;
u[s[i]-'A']--;
s[i]='.';
}
}
}
for(int i=;i<s.size();i++)
{
if(s[i]=='.')
continue;
if('a'<=s[i]&&s[i]<='z')
{
if(u[s[i]-'a']>)
{
b++;
u[s[i]-'a']--;
s[i]='.';
}
}
else
{
if(l[s[i]-'A']>)
{
b++;
l[s[i]-'A']--;
s[i]='.';
}
}
}
cout<<a<<" "<<b<<endl;
return ;
}

Codeforces Round #293 (Div. 2) B. Tanya and Postcard 水题的更多相关文章

  1. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  2. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  3. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  4. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  5. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

  6. Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  7. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

  8. Codeforces Round #384 (Div. 2) A. Vladik and flights 水题

    A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...

  9. Codeforces Round #379 (Div. 2) D. Anton and Chess 水题

    D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...

随机推荐

  1. 嵌入式Linux截图工具gsnap移植与分析【转】

    转自:http://blog.csdn.net/lu_embedded/article/details/53934184 版权声明:开心源自分享,快乐源于生活 —— 分享技术,传递快乐.转载文章请注明 ...

  2. Android调试大法 自定义IDE默认签名文件==>微信支付、微信登录、微信分享,debug时调试通过,release时调不起微信

    转载地址:http://blog.yanzhenjie.com Android调试大法之自定义IDE默认签名文件,你是否为调试第三方SDK时debug签名和release签名发生冲突而烦恼?你是否在d ...

  3. caffe卷积操作

  4. python_接口自动化测试框架

    本文总结分享介绍接口测试框架开发,环境使用python3+selenium3+unittest+ddt+requests测试框架及ddt数据驱动,采用Excel管理测试用例等集成测试数据功能,以及使用 ...

  5. ROSCon 2017通知 Announcing ROSCon 2017: September 21st and 22nd in Vancouver

    ROSCon 2017通知:9月21日和22日在温哥华 我们很高兴地宣布,2017年ROSCon将在举行9月21-22日,2017年温哥华会议中心在加拿大温哥华.2017年IROS将在同一地点9月24 ...

  6. 用戶登陸。防SQL注入,驗證碼不區分大小寫。。

    if (string.Compare(TBCheckCode.Text, Session["CheckCodeI"].ToString(), true) == 0)        ...

  7. 在SQL中有时候我们需要查看现在正在SQL Server执行的命令

    在SQL中有时候我们需要查看现在正在SQL Server执行的命令.在分析管理器或者Microsoft SQL Server Management Studio中,我们可以在"管理-SQL  ...

  8. Ubuntu 搭建docker registry 私有仓库

    一.为什么要搭建 docker 私有仓库 原因有几个: 项目需要,不希望将项目放到 docker hub 上. 环境需求,考虑网络.效率的问题,希望在私有服务器上建立自用的仓库,提高便利性和访问速度. ...

  9. java小爬虫

    爬取煎蛋网 1.找出页面网址的规律 2.设计页面图片网址的正则 代码: import java.io.BufferedInputStream; import java.io.BufferedOutpu ...

  10. CVE-2009-3459

     Adobe Acrobat和Reader都是美国Adobe公司开发的非常流行的PDF文件阅读器.         Adobe Reader和Acrobat 7.1.4之前的7.x版本,8.1.7之前 ...