P1288 - [蓝桥杯2016初赛]密码脱落 - New Online Judge (ecustacm.cn)
方法一:DP(线性DP)((最长公共子序列模型)
求S和reverse(S)的最长公共子序列,用len(S)-最长公共子序列,就是需要增加的种子(即之前掉落种子)才能构成回文串
代码简单但不好想到这方面
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
string s, t;
int f[N][N];
int main()
{
while(cin >> s)
{
memset(f, 0, sizeof f);
t = s;
reverse(t.begin(), t.end());
s = "*" + s;
t = "*" + t;
int len = s.length();
for(int i = 1; i < len; i ++ )
{
for(int j = 1; j < len; j ++ )