为什么会RE?求教

P1435 [IOI2000] 回文字串

我用 char 做了和您用 string 一样的事: ```cpp #include<bits/stdc++.h> using namespace std; int l; char str[5000],str2[5000]; int dp[5000][5000]; int main(){ scanf("%s",str); l=strlen(str); for(int i=0;i<l;++i){ str2[i]=str[l-i-1]; } for(int i=1;i<=l;++i){ for(int j=1;j<=l;++j){ if(str[i-1]==str2[j-1]){ dp[i][j]=dp[i-1][j-1]+1; }else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } cout<<l-dp[l][l]<<endl; return 0; } ``` [AC 记录](https://www.luogu.com.cn/record/144656799) (因为 string 和 char 作占的空间不一样,char 相对 string 所占空间较小)
by XXh0919 @ 2024-01-27 16:52:57


@[GraphAKMeRyan](/user/670978)
by XXh0919 @ 2024-01-27 17:22:59


@[XXh0919](/user/814145) 也就是说string占的空间太大?
by GraphAKMeRyan @ 2024-01-28 08:34:55


@[GraphAKMeRyan](/user/670978) 是的
by XXh0919 @ 2024-01-28 09:11:26


谢谢大佬
by GraphAKMeRyan @ 2024-01-28 09:21:46


|