| ||||||||||
| 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 | |||||||||
帮忙看看程序,我用dp,但是为什么一直WA?/*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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator