5164: 等效字符串

内存限制:256 MB 时间限制:2 S
题面:传统 评测方式:文本比较 上传者:
提交:4 通过:4

题目描述

今天在关于字符串的讲座上,杰拉尔德学习了字符串等价性的新定义。在以下两种情况中,长度相等的两个字符串a和b被称为等价:

1.他们是相等的。

2.如果我们将字符串a拆分为大小相同的a1a2的两半,将字符串b拆分为大小相同的b1b2的两半,则以下其中一项是正确的:

    a1等于b1a2等于b2

    a1等于b2a2等于b1

作为一项家庭任务,老师给学生两个字符串,并要求确定它们是否相等。

杰拉尔德已经完成了这项家庭任务。现在轮到你了!

Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
  1. They are equal.
  2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct:
    1. a1 is equivalent to b1, and a2 is equivalent to b2
    2. a1 is equivalent to b2, and a2 is equivalent to b1
As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.
Gerald has already completed this home task. Now it's your turn!

Input
The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200000 and consists of lowercase English letters. The strings have the same length.
Output
Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.
Examples
输入
aaba
abaa
输出
YES
输入
aabb
abab
输出
NO
Note
In the first sample you should split the first string into strings "aa" and "ba", the second one − into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".
In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".

输入格式

输入的前两行包含老师给出的两个字符串。每个字母的长度从1200000,由小写英文字母组成。字符串的长度相同。

输出格式

如果这两个字符串相等,则打印“YES”(不带引号),否则打印“NO”(不含引号)。

输入
aaba
abaa
输出
YES
输入
aabb
abab
输出
NO

注意

在第一个示例中,您应该将第一个字符串拆分为字符串“aa”“ba”,将第二个字符串拆分成字符串“ab”“aa”“aa”等同于“aa”“ab”等同于“ba”,即“ab”=“a”+“b”“ba”=“b”+“a”

在第二个示例中,第一个字符串可以拆分为字符串“aa”“bb”,这两个字符串仅等同于它们自己。这就是为什么字符串“aabb”仅等同于自身和字符串“bbaa”

输入样例 复制

aaba
abaa

输出样例 复制

YES