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

帮忙看看程序,我用dp,但是为什么一直WA?

Posted by gamy at 2009-07-13 20:29:03 on Problem 2192
/*author by gamy*/
#include<iostream>
#include<string>
#include<map>
#include<deque>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 203

char A[N],B[N],C[2*N];

int main()
{
	int ca,k;
	cin>>ca;
	for(k=1;k<=ca;k++)
	{
		cin>>A>>B>>C;
		cout<<"Data set "<<k<<": ";
		int i,j;
		bool F[N][N];
		F[1][0]=(A[0]==C[0]);
		F[0][1]=(B[0]==C[0]);
		for(i=1;i<=(int)strlen(A);i++)
		{
			for(j=1;j<=(int)strlen(B);j++)
			{
				F[i][j]=F[i][j-1]&&(B[j-1]==C[i+j-1])||F[i-1][j]&&(A[i-1]==C[i+j-1]);
			}
		}
		if(F[(int)strlen(A)][(int)strlen(B)])
			cout<<"yes\n";
		else cout<<"no\n";
	}
}

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