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

最新文章

  1. 《微软互联网信息服务(IIS) 最佳实践》已上市,欢迎选购!
  2. Apache开启状态查看页面(原创贴-转载请注明出处)
  3. Data Binding和INotifyPropertyChanged是如何协调工作的?
  4. Jedis下的ShardedJedis(分布式)使用方法(一)
  5. Saltstack之Syndic(十)
  6. HDU 5087 (线性DP+次大LIS)
  7. 小P的图论课 (模拟退火)
  8. 重学STM32---(六)DAC+DMA+TIM
  9. C#&amp;java重学笔记(面向对象)
  10. 一个优秀的http实现框架
  11. todoing
  12. winform timespan 两个时间的间隔(差) 分类: WinForm 2014-04-15 10:14 419人阅读 评论(0) 收藏
  13. Qt部件学习之-烧鹅
  14. C#最基本的小说爬虫
  15. May 31. 2018 Week 22nd Thursday
  16. MySQL5.6复制技术(4)-MySQL主从复制过滤参数
  17. 装B必备之 快捷键配置
  18. java-mybaits-00201-DAO-SqlSession使用范围
  19. VMware Workstation 14 pro License Keys
  20. SaltStack配置salt-api第十二篇

热门文章

  1. Oracle JDeveloper 10g 卡顿、花屏的解决方法
  2. Oracle 函数 “申请通过后,将该表中循环遍历到的所有内容插到另一个表中”
  3. 洛谷P1195口袋的天空
  4. WiFi无线连接真机进行Appium自动化测试方法
  5. who am i ?
  6. PHP性能调优,PHP慢日志---善用php-fpm的慢执行日志slow log,分析php性能问题
  7. ASP.NET MVC下判断用户登录和授权状态方法
  8. Bootstrap Paginator分页插件使用示例
  9. loadrunner添加变量检查点
  10. Web_add_cookie的作用