#C9978. Scrambled String Detection

    ID: 54130 Type: Default 1000ms 256MiB

Scrambled String Detection

Scrambled String Detection

Given two strings s1 and s2, determine whether s2 is a scrambled version of s1. A scrambled string is defined recursively as follows:

1. If ( s1 = s2 ), then s2 is a scrambled string of s1.
2. If we can split ( s1 ) into two non-empty parts ( s1 = s1_{left} + s1_{right} ), then s2 is a scrambled string of s1 if and only if either:
    a) ( s2 = s2_{left} + s2_{right} ) with ( s1_{left} ) being a scrambled string of ( s2_{left} ) and ( s1_{right} ) being a scrambled string of ( s2_{right} ), or
    b) ( s2 = s2_{left} + s2_{right} ) with ( s1_{left} ) being a scrambled string of ( s2_{right} ) and ( s1_{right} ) being a scrambled string of ( s2_{left} ).

Your task is to write a program that reads two strings from standard input and determines whether the second string is a scrambled version of the first string.

inputFormat

The input consists of two lines. The first line contains the string s1, and the second line contains the string s2. Both strings contain only lowercase letters.

outputFormat

Output a single line that is either 'True' or 'False', indicating whether s2 is a scrambled version of s1.## sample

great
rgeat
True