Title Link: http://www.lightoj.com/volume_showproblem.php?problem=1033
Test instructions: Add at least a few characters to make a given string into a palindrome string.
Solution: The end of the lifting point, the DP;
Code:
#include <stdio.h>#include <ctime>#include <math.h>#include <limits.h>#include <complex>#include <string>#include <functional>#include <iterator>#include <algorithm>#include <vector>#include <stack>#include <queue>#include <set>#include <map>#include <list>#include <bitset>#include <sstream>#include <iomanip>#include <fstream>#include <iostream>#include <ctime>#include <cmath>#include <cstring>#include <cstdio>#include <time.h>#include <ctype.h>#include <string.h>#include <assert.h>using namespace STD;intTChars[1010];intdp[1010][1010];intMain () {scanf("%d", &t); for(intCA =1; CA <= t;ca++) {memset(DP,0,sizeof(DP));scanf('%s ', s+1);intn =strlen(s+1); for(inti = n; I >=1; i--) for(intj = i+1; J <= N; J + +) {if(S[i] = = S[j]) dp[i][j] = Dp[i +1][j-1];ElseDp[i][j] = min (dp[i+1][j],dp[i][j-1]) +1; }printf("Case%d:%d\n", ca,dp[1][n]); }return 0;}
Lightoj 1033-generating palindromes "Interval DP"