I'm bored of wrong answer....
I get wa many times.
whats the wrong here????
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<memory.h>
#define MAX 10000
char X[MAX],Y[MAX],string[MAX],store[MAX];
int i,j,m,n,c[MAX][MAX],b[MAX][MAX],k=0;
int LCSlength()
{
m=strlen(X);
n=strlen(Y);
for(i=1;i<=m;i++)
{
c
[0]=0;
}
for(j=0;j<=m;j++)
{
c[0][j]=0;
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
if(X[i-1]==Y[j-1])
{
c[j]=c[i-1][j-1]+1;
b[j]=1;
}
else if(c[i-1][j]>=c[j-1])
{
c[j]=c[i-1][j];
b[j]=2;
}
else
{
c[j]=c[j-1];
b[j]=3;
}
}
}
return c[m][n];
}
void PrintLCS(int i,int j)
{
if(i==0 || j==0)return;
if(b[j]==1)
{
PrintLCS(i-1,j-1);
store[k]=X[i-1];
k++;
}
else if(b[i][j]==2)PrintLCS(i-1,j);
else PrintLCS(i,j-1);
}
int main()
{
char c,*p;
int l;
while(gets(string))
{
memset(store,NULL,sizeof(store));
k=0;
p=strtok(string," ");
strcpy(X,p);
p=strtok(NULL," ");
strcpy(Y,p);
LCSlength();
PrintLCS(m,n);
if(strcmp(X,store)==0)printf("Yes\n");
else printf("No\n");
}
}