#K81617. Taco Transformation
Taco Transformation
Taco Transformation
You are given two strings S and T. Your task is to determine whether it is possible to transform S into T using the following operation:
- If the multisets of characters in S and T are identical (i.e. \(\text{sorted}(S)=\text{sorted}(T)\)), a transformation is possible.
The minimum number of operations is defined as follows:
- If S equals T, then 0 operations are required.
- If S does not equal T but the transformation is possible, then 1 operation suffices.
- If the multisets differ, then the transformation is impossible.
Output NO
if the transformation is not possible. Otherwise, output YES 0
or YES 1
depending on the number of operations needed.
inputFormat
The first line contains an integer N (\(1 \leq N \leq 1000\)), representing the number of test cases. For each test case, there are two lines:
- The first line contains the string S.
- The second line contains the string T.
Both S and T consist of uppercase English letters.
outputFormat
For each test case, output a single line. If the transformation is not possible, print NO
. If it is possible, print YES 0
if no operation is required (i.e. S equals T), otherwise print YES 1
.
2
ABC
CBA
XYZ
XYZ
YES 1
YES 0
</p>