标签:bsp strcmp ret shuffle \n div algo style bre
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring> 5 #include <algorithm> 6 #include <queue> 7 using namespace std; 8 struct node 9 { 10 int x, step; 11 }s,e; 12 int n, m,vis[10010],sum=0; 13 char s1[150],s2[150],s3[250],t1[150],t2[150],t3[250]; 14 int main() 15 { 16 int t,step,flag,sum=0; 17 scanf("%d",&t); 18 while (t--) 19 { 20 scanf("%d",&n); 21 scanf("%s",s1); 22 scanf("%s",s2); 23 scanf("%s",s3); 24 strcpy(t1,s1); 25 strcpy(t2,s2); 26 strcpy(t3,s3); 27 step=0;flag=0;sum++; 28 while(1) 29 { 30 step++; 31 for(int i=0;i<n;i++) 32 { 33 t3[2*i]=t2[i]; 34 t3[2*i+1]=t1[i]; 35 } 36 if(strcmp(t3,s3)==0) 37 { 38 flag=1; 39 break; 40 } 41 for(int i=0;i<n;i++) 42 { 43 t1[i]=t3[i]; 44 t2[i]=t3[n+i]; 45 } 46 if(strcmp(t1,s1)==0&&strcmp(t2,s2)==0) 47 { 48 break; 49 } 50 } 51 if(flag) 52 printf("%d %d\n",sum,step); 53 else 54 printf("%d -1\n",sum); 55 } 56 return 0; 57 }
标签:bsp strcmp ret shuffle \n div algo style bre
原文地址:https://www.cnblogs.com/huluxin/p/9313621.html