20pts求助,悬赏1关注

P1435 [IOI2000] 回文字串

``` #include <iostream> #include <string> #include <algorithm> using namespace std; string f,d; int n,dp1[1005],dp2[1005]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>f; d=f; n=f.length(); reverse(d.begin(),d.end()); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(f[i]==d[j]){ dp1[j+1]=dp2[j]+1; } else{ dp1[j+1]=max(dp1[j],dp2[j+1]); } } for(int k=0;k<=n;k++)dp2[k]=dp1[k]; } cout<<n-dp1[n]<<endl; return 0; } ```
by OutsideR_ @ 2024-03-19 19:25:24


这不就是对的吗
by SMZYWACR @ 2024-03-19 20:10:02


你提交的20分没有加 **for(int k=0;k<=n;k++)dp2[k]=dp1[k];** 应该是复制错了
by SMZYWACR @ 2024-03-19 20:16:59


@[SMZYWACR](/user/541499) 非常感谢(不知道为啥,估计是没复制上去)
by OutsideR_ @ 2024-03-23 18:29:02


|