解题思路:普通模拟题

#include < iostream >
#include < string >
#include < set >
using namespace std;
int main()
{
set < string > shuf;
char s1[ 101 ],s2[ 101 ];
string aim,str;
int i,j,n,m,iter;
bool IsFind;
cin >> n;
for (i = 1 ;i <= n;i ++ )
{
iter = IsFind = 0 ;
cin >> m >> s1 >> s2 >> aim;str.resize( 2 * m);
while ( 1 )
{
iter ++ ;
for (j = 0 ;j < m;j ++ )str[j * 2 ] = s2[j],str[j * 2 + 1 ] = s1[j];
for (j = 0 ;j < m;j ++ )s1[j] = str[j],s2[j] = str[j + m];
if (str == aim){IsFind = true ; break ;}
if (shuf.find(str) == shuf.end())
shuf.insert(str);
else break ;
}
shuf.clear();
cout << i << " " << (IsFind ? iter : - 1 ) << endl;;
}
return 0 ;
}