D. Equivalent Strings
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <string>7#include <vector>8#include <Set>9#include <map>Ten#include <queue> One#include <sstream> A using namespacestd; - typedef __int64 LL; - Const intINF =0x4ffffff; the Const DoubleEXP = 1e-5; - ConstLL mod = 1e9+7; - Const intms=200005; - + - BOOLequalsstringS1,stringS2) + { A intLen1 =s1.size (); at intLen2 =s2.size (); - if(S1 = =S2) - return true; - Else if(len1! = Len2 | | (len1&1) ==1|| (Len2 &1) ==1) - return false; - Else in { - //if (Equals (S1.substr (0,LEN1/2), S2.substr (0,LEN1/2)) && equals (S1.substr (LEN1/2,LEN1/2), S2.substr (len1 /2,LEN1/2 ))) to //return true; //do not put this back will time out, because the front S1 = = S2 did not pass. Indicates that there are different characters in the same position. Cross comparison can be optimized first. + - if(Equals (S1.substr (0, len1/2), S2.substr (len1/2, len1/2)) && equals (S1.substr (len1/2, len1/2), S2.substr (0, len1/2))) the return true; * if(Equals (S1.substr (0, len1/2), S2.substr (0, len1/2)) && equals (S1.substr (len1/2, len1/2), S2.substr (len1/2, len1/2))) $ return true;Panax Notoginseng - return false; the } + } A the + intMain () - { $ strings1,s2; $Cin>>s1>>S2; - if(Equals (S1,S2)) -printf"yes\n"); the Else -printf"no\n");Wuyi return 0; the}
D. Equivalent Strings