Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

数据过了WA 直接模拟的 附代码

Posted by DreamBro at 2019-07-23 10:17:43 on Problem 3087
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator