#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int n,m,loc[N],stk[N],tp;
int f[N][N];
char s[N],s1[N];
int main()
{
scanf("%s%s",s+1,s1+1);
n=strlen(s+1);
m=strlen(s1+1);
for(int i=1;i<=n;i++)
{
if(s[i]!='.')
{
stk[++tp]=i;
}
else
{
loc[stk[tp--]]=i;
}
}
memset(f,63,sizeof f);
f[0][0]=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=m;j++)
{
if(loc[i])
{
f[loc[i]][j]=min(f[loc[i]][j],f[i-1][j]);
}
if(j!=0)
{
if(s[i]==s1[j])
{
f[i][j]=min(f[i][j],f[i-1][j-1]);
}
}
f[i][j]=min(f[i][j],f[i-1][j]+1);
}
}
printf("%d\n",f[n][m]);
return 0;
}
以上代码为什么在使用被注释掉的定义方式时会WA,而未注释的AC。