P13491 【MX-X14-T1】Gene Splicing

Description

Little A gives you two strings $S$ and $T$, each of length $n$. He wants to know whether $S$ can be partitioned into several substrings\* and then concatenated in any order to form $T$. \*A substring is defined as a **contiguous** segment of characters from the original string.

Input Format

The first line contains an integer $n$. The second line contains a string $S$ of length $n$. The third line contains a string $T$ of length $n$. It is guaranteed that $S$ and $T$ consist only of lowercase English letters.

Output Format

Output a single line with the string `Yes` or `No`, indicating whether $S$ can be transformed into $T$ by partitioning it into substrings and concatenating them in any order.

Explanation/Hint

**【Sample Explanation #1】** $S$ can be partitioned into two substrings, $\texttt{xyz}$ and $\texttt{ab}$, and then concatenated in reverse order to form $\texttt{abxyz}$. **【Sample Explanation #2】** $S$ can be partitioned into $\texttt{aa}$, $\texttt{b}$, and $\texttt{bcc}$, and then concatenated to form $\texttt{bccaab}$. **【Sample Explanation #3】** It can be proven that no matter how $S$ is partitioned and concatenated, it cannot be transformed into $T$. **【Data Range】** For $10\%$ of the data, $n \le 10$. For $30\%$ of the data, $n \le 20$. For $60\%$ of the data, $n \le 10^3$. For $100\%$ of the data, $1 \le n \le 10^5$, and it is guaranteed that $S$ and $T$ consist only of lowercase English letters. --- *Translated by DeepSeek V3.*