因为$f[i][j-1], f[i+1][j-1]$ 涉及 f[i][0]
以此定义状态, f[i][0] = 0
@[Chouquet](/user/207812)
by Alphaban @ 2020-09-09 22:01:19
@[Chouquet](/user/207812) 求求大佬帮帮忙
[呜呜](https://www.luogu.com.cn/discuss/show/255791)
by Alphaban @ 2020-09-09 22:02:16
```cpp
#include <cstdio>
#include <cstring>
#define min(a,b) ((a)<(b)?(a):(b))
char s[1003];
int len,f[1003][1003];
int main(){
scanf("%s",s+1),len=strlen(s+1);
memset(f,0x3f,sizeof f);
for(int i=1;i<=len;i++) f[i][i]=f[i][0]=0;
for(int i=len-1;i>=1;i--)
for(int j=i+1;j<=len;j++){
if(s[i]==s[j]&&i+1<=j-1) f[i][j]=f[i+1][j-1];
else f[i][j]=min(f[i+1][j],f[i][j-1])+1;
}
printf("%d\n",f[1][len]);
return 0;
}
```
这个?@[IcproX](/user/112109)
by Chouquet @ 2020-09-09 22:19:30
@[Chouquet](/user/207812)
求助
https://www.luogu.com.cn/discuss/show/255791
by Alphaban @ 2020-09-09 22:22:45
@[Chouquet](/user/207812) 这个是错的原因我说过了
by Alphaban @ 2020-09-09 22:23:20
@[IcproX](/user/112109) f[i][0]置为0了啊
by Chouquet @ 2020-09-09 22:25:48
应该没有问题把
by Chouquet @ 2020-09-09 22:29:14
@[Chouquet](/user/207812) qp%cq
by Dry_ice @ 2020-09-09 23:25:46