T - Amusing Joke(map)
Problem description
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
解题思路:题目的意思就是将第一行字符串和第二行的字符串中的字母随机打乱顺序并且拼接起来和第三行的字符串比较,如果第三行的字符串刚好为前两行字符串中的字母组成,则输出"YES",否则输出"NO"。做法:采用map容器,键为字母序号,值为该字母出现的次数,如果前两行每个字母出现的次数和第三行对应字母出现的次数都相同,则输出"YES",否则输出"NO",水过。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
map<int,int> mp1,mp2;
for(int i=;i<;++i)mp1[i]=mp2[i]=;
char s1[],s2[],s3[];
cin>>s1>>s2>>s3;
for(int i=;s1[i]!='\0';++i)mp1[s1[i]-'A']++;
for(int i=;s2[i]!='\0';++i)mp1[s2[i]-'A']++;
for(int i=;s3[i]!='\0';++i)mp2[s3[i]-'A']++;
bool flag=false;
for(int i=;i<;++i)
if(mp1[i]!=mp2[i]){flag=true;break;}
if(flag)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return ;
}
T - Amusing Joke(map)的更多相关文章
- Codeforce 141A - Amusing Joke (sort)
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests a ...
- GO语言总结(4)——映射(Map)
上一篇博客介绍了Go语言的数组和切片——GO语言总结(3)——数组和切片,本篇博客介绍Go语言的映射(Map) 映射是一种内置的数据结构,用来保存键值对的无序集合. (1)映射的创建 make ( m ...
- Java-集合=第五题 (Map)设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得该Account 对象能够自动分配id。 给定一个List 如下: List list = new ArrayList(); list.add(new A
第五题 (Map)设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得 ...
- Java-map-第一题 (Map)利用Map,完成下面的功能: 从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队。如果该 年没有举办世界杯,则输出:没有举办世界杯。 附:世界杯冠军以及对应的夺冠年份,请参考本章附录。 附录
第一题 (Map)利用Map,完成下面的功能: 从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队.如果该 年没有举办世界杯,则输出:没有举办世界杯. 附:世界杯冠军以及对应的夺冠年 ...
- 第一题 (Map)利用Map,完成下面的功能:
从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队.如果该 年没有举办世界杯,则输出:没有举办世界杯. 附:世界杯冠军以及对应的夺冠年份,请参考本章附录. 附录 1.历届世界杯冠 ...
- 【机器学习基本理论】详解最大似然估计(MLE)、最大后验概率估计(MAP),以及贝叶斯公式的理解
[机器学习基本理论]详解最大似然估计(MLE).最大后验概率估计(MAP),以及贝叶斯公式的理解 https://mp.csdn.net/postedit/81664644 最大似然估计(Maximu ...
- 【机器学习基本理论】详解最大后验概率估计(MAP)的理解
[机器学习基本理论]详解最大后验概率估计(MAP)的理解 https://blog.csdn.net/weixin_42137700/article/details/81628065 最大似然估计(M ...
- GoLang基础数据类型--->字典(map)详解
GoLang基础数据类型--->字典(map)详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 可能大家刚刚接触Golang的小伙伴都会跟我一样,这个map是干嘛的,是 ...
- 列表生成式+过滤器(filter)+映射(map)+lambda总结
这些都是python的特色,不仅强大,而且好用,配合起来使用更是无敌. 零.lambda lambda用于产生一个匿名表达式,组成部分为:lambda + ‘函数表达式’ ‘函数表达式’由一个冒号加上 ...
随机推荐
- mysql5.7初始化密码报错ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstateme
1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password 或者:grep 'temporary ...
- Weex框架源码分析(Android)(一)
一.weexSDK初始化流程 WXSDKEngine.initialize(Application application,InitConfig config); //WXSDKEngine的init ...
- Django - 一对多创建
1.新创建一个app python manage.py startapp app01 2.在django的setting.py中,填加新增的app名称 3.在app01的models.py中,添加代码 ...
- asp网站中使用百度ueditor教程.txt
1.根据网站类型及编码选择相应的ueditor版本,如我的网站编码为gb2312,则选择ueditor 1.43 asp gbk版.2.本机IE浏览器应为8.0或以上,8.0以下的ueditor 1. ...
- 水图(牛客练习赛(DFS搜索))
题意: 小w不会离散数学,所以她van的图论游戏是送分的 小w有一张n个点n-1条边的无向联通图,每个点编号为1~n,每条边都有一个长度小w现在在点x上她想知道从点x出发经过每个点至少一次,最少需要走 ...
- 第二节:web爬虫之lxml解析库
lxml是python的一个解析库,支持HTML和XML的解析,支持XPath解析方式,而且解析效率非常高.
- everyday two problems / 3.1
T1.string 题意: 给定由小写字母组成的长度为 n 的字符串 将其所有 n * (n + 1) / 2 个子串按字典序排序 输出第 k 个子串 k > (n * (n + 1) / 2) ...
- 使用MySQLMigrationToolkit快速将Oracle数据导入MySQL
使用MySQL Migration Toolkit快速将Oracle数据导入MySQL 上来先说点废话 本人最近在学习一些数据库方面的知识,之前接触过Oracle和MySQL,最近又很流行MongoD ...
- Django获取当前页面的URL——小记
获取带参数URL:request.get_all_path() 获取不带参数URL:request.path 获取主机地址:request.get_host()
- nyoj_289_苹果_20140307
苹果 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 ctest有n个苹果,要将它放入容量为v的背包.给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值. ...