一开始把它当成暴力来做了,即,从终点开始,枚举其最长的回文串,一旦是最长的,马上就ans++,再计算另外的部分...结果WA了 事实证明就是一个简单DP,算出两个两个点组成的线段是否为回文,再用LCS的类似做法得到每个子结构的最优值. #include <cstdio> #include <cstring> #define N 1010 char s[N]; int n,len,d[N][N],sum[N]; int min(int a,int b) { if (a<b) r…
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is the same written forwards and backwards. For example, ‘racecar’ is a palindrome, but ‘fastcar’ is not. A partition of a sequence of characters is a lis…
Partitioning by Palindromes Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Practice UVA 11584 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ]; int C(int x,int…