P26350 [AtCoder] Alchemist
普及+
题目描述

Problem Description

Takahashi is a professional alchemist.

In this world, metals have names consisting of $2N$ characters (where $N$ is an integer), and all names are composed of uppercase alphabetic letters.

The condition for Takahashi to be able to alchemize a new metal $S3$ from existing metals $S1$ and $S2$ is that by taking $N$ characters from each of $S1$ and $S2$, and rearranging these characters, the result matches $S3$.

Given the names of three metals $S1$, $S2$, and $S3$, determine if $S3$ can be alchemized from $S1$ and $S2$.

Input Format

The input is given from the standard input in the following format:

$ S1 $ $ S2 $ $ S3 $

  • The first line contains the name of the first metal used as material for alchemy, $S1$.
  • The second line contains the name of the second metal used as material for alchemy, $S2$.
  • The third line contains the name of the desired metal, $S3$.
  • $S1$, $S2$, and $S3$ are composed only of uppercase alphabetic letters.
  • The lengths of $S1$, $S2$, and $S3$ are equal and even.
  • $2 ≦ |S1| ≦ 10^5$ always holds.

Output Format

Output YES if $S3$ can be alchemized from $S1$ and $S2$, otherwise output NO in one line.

Sample Input and Output

Sample Input #1

AABCCD
ABEDDA
EDDAAA

Sample Output #1

YES

Sample Input #2

AAAAAB
CCCCCB
AAABCB

Sample Output #2

NO

Notes/Hints

Sample Explanation 1

By taking AAD from the first metal and AED from the second metal, you can create EDDAAA.

Sample Explanation 2

You must take at least 4 characters from the first metal, so it is not possible to alchemize.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
AABCCD ABEDDA EDDAAA
样例输出
YES