A. Amusing Joke

题目链接:http://codeforces.com/problemset/problem/141/A

141A. Amusing Joke

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output

题目描述
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”.

题意:输入的第一个字符串与第二个字符串合并,合并后与第三个字符串进行比较,判断合并后的字符串与第三个字符串里所含有的字母是否全部相同。
解题思路:sort排序后一一比对即可。

代码

#include<bits/stdc++.h>
#include<cstring>
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 0;
}


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

稚皓君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值