- #include <bits/stdc++.h>
- using namespace std;
- int dp[201][201];
- int l;
- string s;
- int go(int i, int j){
- if(i>j){
- return 0;
- }
- if(dp[i][j]!= -1){
- return dp[i][j];
- }
- if(s[i] == s[j]){
- return go(i+1, j-1);
- }
- dp[i][j] = 1+min(go(i+1,j), go(i, j-1));
- return dp[i][j];
- }
- int main()
- {
- int ts, cs = 1;
- cin>>ts;
- while(ts--){
- memset(dp, -1, sizeof(dp));
- cin>>s;
- l = s.length();
- printf("Case %d: %d\n", cs++, go(0, l-1));
- }
- return 0;
- }
Thursday 27 July 2017
Lightoj 1033 - Generating Palindromes
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
Problem link: Problem Analysis: It is actually a basic Bisection problem , as we can see here we can not actually find a formula fo...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
No comments:
Post a Comment