#C5084. Reversible Substring Transformation

    ID: 48694 Type: Default 1000ms 256MiB

Reversible Substring Transformation

Reversible Substring Transformation

Given two strings S and T of equal length \(n\), determine whether S can be transformed into T by performing a series of operations. In each operation, you may reverse any non-empty substring of the string.

The reversal operation preserves the multiset of characters. In other words, the transformation is possible if and only if the sorted order of characters of S is equal to that of T, i.e., \(\text{sorted}(S)=\text{sorted}(T)\).

Output YES if such a transformation is possible, or NO otherwise.

inputFormat

The input consists of three lines:

  1. An integer (n) representing the length of the strings.
  2. A string (S) of length (n).
  3. A string (T) of length (n).

It is guaranteed that the lengths of (S) and (T) are equal.

outputFormat

Output a single line containing either "YES" if (S) can be transformed into (T) using the allowed operations, or "NO" otherwise.## sample

6
abcdef
fedcba
YES

</p>