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

Codeforce 141A - Amusing Joke (sort)的更多相关文章

  1. T - Amusing Joke(map)

    Problem description So, the New Year holidays are over. Santa Claus and his colleagues can take a re ...

  2. JS中的算法与数据结构——排序(Sort)(转)

    排序算法(Sort) 引言 我们平时对计算机中存储的数据执行的两种最常见的操作就是排序和查找,对于计算机的排序和查找的研究,自计算机诞生以来就没有停止过.如今又是大数据,云计算的时代,对数据的排序和查 ...

  3. JS中的算法与数据结构——排序(Sort)

    排序算法(Sort) 引言 我们平时对计算机中存储的数据执行的两种最常见的操作就是排序和查找,对于计算机的排序和查找的研究,自计算机诞生以来就没有停止过.如今又是大数据,云计算的时代,对数据的排序和查 ...

  4. 【阿里巴巴Java开发手册——集合处理】13.集合的稳定性(order)和有序性(sort)

    有序性(sort):指遍历的结果是按照某种比较规则依次排列的. 稳定性(order):指集合每次遍历的元素的次序是一定的. 如:ArrayList是order/unsort HashMap是unord ...

  5. MongoDB入门---文档查询之$type操作符&limit方法&skip方法&简单排序(sort)操作

    上一篇文章呢,已经分享过了一部分查询操作了,这篇文章呢?就来继续分享哈.接下来呢我们直接看MongoDB中的$type操作符哈.它呢是基于BSON类型来检索集合中匹配的数据类型,并且返回结果,在Mon ...

  6. BZOJ3990 排序(sort)

    排序(sort) 题目描述 小A有一个1~2N的排列A[1..2N],他希望将数组A从小到大排序.小A可以执行的操作有N种,每种操作最多可以执行一次.对于所有的i(1<=i<=N),第i种 ...

  7. 洛谷P1654 产品排序(sort)

    P1654 产品排序(sort) 题目描述 有一系列产品,给定每个产品的加工时间和冷却成型时间(冷却过程产品之间没有关系,是单独冷却的).现在你手上有两台机器可以用来加工,你需要安排产品加工的顺序以及 ...

  8. 结构体快排回顾(sort)

    一般来说,我做竞赛的时候排序一般用快排 很快很方便 普通sort(从小到大) sort(a,a+n); 直接贴一段代码吧,包含了vector,sort,结构体等简单东西综合 #include < ...

  9. Python:如何排序(sort)

    一.前言 对Python的列表(list)有两个用于排序的方法: 一个是内建方法list.sort(),可以直接改变列表的内容: >>> list1 = [9,8,7,6,5] &g ...

随机推荐

  1. css—动画(transform, transition, animation)

    transform 静态属性,一旦写进style里面,会立即显示作用,无任何变化过程.(类似于left, right, top, bottom这类属性) 主要用来做元素的变形 改变元素样式的属性主要有 ...

  2. JMeter接口测试-循环读取库的用户信息

    前言 如何实现循环读取数据库的用户信息,并传递到下一个登录请求呢,下面我们一起来学习吧!在之前我们已经学会了利用JMeter连接数据库了,具体操作可以看我之前的随笔JMeter接口测试-JDBC测试 ...

  3. [PHP] 使用PHP在mongodb中进行count查询

    在php7的mongodb扩展中,当要查询某个集合在某个条件下的数据个数时,可以使用下面的方式来获取. 比原生的命令要复杂许多 比旧版mongo扩展也复杂许多 需要使用到MongoDB\Driver\ ...

  4. Dynamics 365 marketing中添加自定义渠道磁贴

    Dynamics 365 marketing中默认的渠道只有Marketing Email和Marketing Activity,想要添加其他渠道必须自定义磁贴,自定义磁贴的步骤如下: 1.创建实体 ...

  5. AndroidStudio跑起来第一个App时新手遇到的那些坑

    场景 当你看了一个Android教程,满心欢喜想要运行第一个HelloWorld时却发现,Android Studio新建的工程老是报错. 会编译不通过.运行按钮灰色.没有虚拟机,一个简简单单的Hel ...

  6. Hadoop-HDFS(HDFS-HA)

    HDFS(Hadoop Distributed File System) 分布式文件系统,HDFS是一个高度容错性的系统,适合部署在廉价的机器上.HDFS能提供高吞吐量的数据访问,非常适合大规模数据集 ...

  7. 记一次Postgres CPU爆满故障

    问题描述 公司项目测试环境调用某些接口的时候,服务器立即崩溃,并一定时间内无法提供服务. 问题排查 服务器配置不够 第一反应是服务器需要升配啦,花钱解决一切!毕竟测试服务器配置确实不高,2CPU + ...

  8. ansible基本使用(一)

    ansible是什么? ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.chef.func.fabric)的优点,实现了批量系统配置.批量程序部署.批量 ...

  9. [Contract] Solidity 判断 mapping 值的存在

    比如 mapping(address => uint) tester,只需要判断 mapping 是否为默认值 0, tester[msg.sender] == 0 "You can ...

  10. MySql优化之主从复制

    第一步: 配置节点信息(配置完毕重启mysql) 找到my.cnf配置文件,这个文件在etc目录下使用命令修改my.cnf文件 vi /etc/my.cnf 主节点配置: server-id =55 ...