| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
数据过了WA 直接模拟的 附代码#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;
char a[1001],b[1001],c[2005];
int main()
{
int i,j;
int N,C;
char s1[1001],s2[1001],s[2005];
scanf("%d",&N);
while(N--)
{
int cnt=0;
int k=0;
bool flag=false;
scanf("%d",&C);
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
strcpy(s1,a);
strcpy(s2,b);
while(1)
{
cnt++;
for(i=0,j=0;i<C;i++)
{
s[j++]=s2[i];
s[j++]=s1[i];
}
s[j]='\0';
if(strcmp(s,c)==0)
{
flag=true;
break;
}
for(i=0,j=0;i<C;i++)
s1[j++]=s[i];
s1[j]='\0';
for(i=C,j=0;i<2*C;i++)
s2[j++]=s[i];
s2[j]='\0';
if(strcmp(s1,a)==0&&strcmp(s2,b)==0)
break;
}
if(flag)
{
printf("%d %d\n",++k,cnt);
}
else
{
printf("%d -1\n",++k);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator