摘要: http://poj.org/problem?id=1159给定一字符串,问最少插入多少字符能使该字符串变成回文串。只要求出该字符串与其逆串的公共子序列,然后然后用n减去就得结果。这里卡内存,可以将f[5007][5007]定义成short int 型,计算后能险过,所以这里最好采用滚动数组。View Code #include <cstdio>#include <cstring>#include <iostream>#define maxn 5005using namespace std;char s[maxn];int f[2][maxn];int ma 阅读全文
posted @ 2012-04-30 15:17 E_star 阅读(132) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1080discuss 里面的解释已经很经典很明白了。http://poj.org/showmessage?message_id=74842View Code #include <cstdio>#include <cstring>#include <iostream>#define maxn 107using namespace std;int f[5][5] ={ {5,-1,-2,-1,-3}, {-1,5,-3,-2,-4}, {-2,-3,5,-2,-2}, {-1,-2,-2,5,-1}, {-3 阅读全文
posted @ 2012-04-30 10:36 E_star 阅读(130) 评论(0) 推荐(0) 编辑