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

题解:将一二句合并,并与第三句进行排序比较

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=;
const int mod=1e9+;
char a[N],c[N];
char b[N];
int main()
{
mem(a);
mem(b);
mem(c);
scanf("%s%s%s",&a,&b,&c);
int m=strlen(a);
int n=strlen(b);
int l=strlen(c);
int flag=;
if(l<m+n) flag=;
for(int i=m;i<n+m;i++){
a[i]=b[i-m];
}
sort(a,a+n+m);
sort(c,c+l);
for(int i=;i<l;i++){
if(a[i]!=c[i]){
flag=;
break;
}
}
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}

网上的另一种写法:字符串排序,简单调用。 sort(a.begin(),a.end());

 #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string a,b,c;
cin>>a>>b>>c;
a+=b;
sort(a.begin(),a.end());
sort(c.begin(),c.end());
if(a==c)
printf("YES\n");
else
printf("NO\n");
return ;
}

最新文章

  1. iOS之App Store上架被拒Legal - 5.1.5问题
  2. IRC(Internet Relay Chat Protocol) Protocal Learning &amp;&amp; IRC Bot
  3. 权限&lt;九&gt;
  4. mysql触发器查看
  5. 算法练习之:Doubles
  6. vue2与vue1的区别
  7. ajax post请求request.getParameter(&quot;&quot;)取值为null
  8. 03_Weblogic之配置简单域:启动和配置域,使用模板创建域,使用控制台
  9. Git merge 不同的branch
  10. ES6 Promise 详解
  11. 10.外观模式(Facade Pattern)
  12. PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /usr/local/php/CreateDB.php on line 5
  13. C# 连接池开发,多连接高效应用开发,多连接自动维护管理。
  14. centos7下安装docker(8.3容器的常用操作)
  15. codeforces580C
  16. ThinkPHP widge使用示例
  17. Intellij新建Spring项目引入用户目录下的Spring jar包
  18. 读写 Excel 工作表
  19. leetcode-位1的个数(位与运算)
  20. webDriver API——第6部分Locate elements By

热门文章

  1. HA: Chanakya Vulnhub Walkthrough
  2. 【Android开发艺术探索】四大组件的工作过程
  3. BOS只读状态修改
  4. 彻底理解Windows认证1
  5. 传智播客C++视频学习笔记(1)
  6. Java基础之四、字符和字符串 异常处理
  7. JS数据类型和堆栈+变量比较和值的复制+参数传递和类型检测
  8. 转载 CXF动态调用webservice
  9. python函数的使用
  10. 如何开启音乐二倍速?不下载其他软件【win10】