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

Re:菜鸟1Y 开心

Posted by v11 at 2011-01-27 23:15:26 on Problem 2192
In Reply To:菜鸟1Y 开心 Posted by:v11 at 2011-01-27 23:14:34
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 500
char s1[N],s2[N],s3[N];
int dp[N][N];
int main()
{
	int n,i,j,k,cas,len1,len2;
	while(~scanf("%d",&n))//printf("Data set %d: no\n",cas+1);
	{
		for(cas=0;cas<n;cas++)
		{
			memset(dp,0,sizeof(dp));
			scanf(" %s %s %s",s1,s2,s3);
			dp[0][0]=1;
			len1=strlen(s1);
			len2=strlen(s2);
			for(i=0;i<=len1;i++)
				for(j=0;j<=len2;j++)
				{
					if(!i&&!j) continue;
					else if(!j&&dp[i-1][0]&&s3[i-1]==s1[i-1])
						dp[i][0]=1;
					else if(!i&&dp[0][j-1]&&s3[j-1]==s2[j-1])
						dp[0][j]=1;
					else {
						if(dp[i-1][j]&&s1[i-1]==s3[i+j-1])
							dp[i][j]=1;
						else if(dp[i][j-1]&&s2[j-1]==s3[i+j-1])
							dp[i][j]=1;
					}
				}
			if(dp[len1][len2]) printf("Data set %d: yes\n",cas+1);
			else printf("Data set %d: no\n",cas+1);
		}
	}
}

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