<p>You are given a string <code>s</code> containing lowercase letters and an integer <code>k</code>. You need to :</p>

<ul>
	<li>First, change some characters of <code>s</code> to other lowercase English letters.</li>
	<li>Then divide <code>s</code> into <code>k</code> non-empty disjoint substrings such that each substring is a palindrome.</li>
</ul>

<p>Return <em>the minimal number of characters that you need to change to divide the string</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abc&quot;, k = 2
<strong>Output:</strong> 1
<strong>Explanation:</strong>&nbsp;You can split the string into &quot;ab&quot; and &quot;c&quot;, and change 1 character in &quot;ab&quot; to make it palindrome.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;aabbc&quot;, k = 3
<strong>Output:</strong> 0
<strong>Explanation:</strong>&nbsp;You can split the string into &quot;aa&quot;, &quot;bb&quot; and &quot;c&quot;, all of them are palindrome.</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;leetcode&quot;, k = 8
<strong>Output:</strong> 0
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= k &lt;= s.length &lt;= 100</code>.</li>
	<li><code>s</code> only contains lowercase English letters.</li>
</ul>

class Solution {
public:
    //int palindromePartition(string s, int k) {
/*int print0(string b,string c,int e,int temp0,int temp2){
    if(e==b.size()){
        if(temp0==temp2){
            return 0;
        }
        return INT_MAX;
    }
    if(temp0==temp2){
        return INT_MAX;
    }
    int temp12=INT_MAX;
    c=c+b[e];
    string temp18="";
    int temp28=0;
    int temp48=0;
    int temp72=c.size()-1;
    while(temp48<=temp72){
        if(c[temp48]==c[temp72]){
            temp48=temp48+1;
            temp72=temp72-1;
        }
        else if(c[temp48]!=c[temp72]){
            temp28=temp28+1;
            temp48=temp48+1;
            temp72=temp72-1;
        }
    }
    temp12=min(temp12,print0(b,temp18,e+1,temp0+1,temp2));
    if(temp12!=INT_MAX){
        temp12=temp12+temp28;
    }
    temp12=min(temp12,print0(b,c,e+1,temp0,temp2));
    c.pop_back();
    return temp12;
}
int palindromePartition(string b,int c){
    int e=0;
    int temp0=0;
    int temp2=0;
    int temp12=0;
    string temp18="";
    temp12=print0(b,temp18,e,temp0,c);
    return temp12;
    }*/
    int print0(string &b,vector<vector<vector<int>>> &c,int e,int temp0,int temp2,int temp12){
    if(e==b.size()){
        if(temp2==temp12){
            return 0;
        }
        return INT_MAX;
    }
    int temp18=0;
    int temp28=temp0;
    int temp48=e;
    int temp72=INT_MAX;
    if(temp2==temp12){
        return INT_MAX;
    }
    if(c[e][temp0][temp2]!=-1){
        return c[e][temp0][temp2];
    }
    while(temp28<=temp48){
       if(b[temp28]==b[temp48]){
        temp28=temp28+1;
        temp48=temp48-1;
       }
       else if(b[temp28]!=b[temp48]){
        temp18=temp18+1;
        temp28=temp28+1;
        temp48=temp48-1;
       }
    }
    temp72=min(temp72,print0(b,c,e+1,e+1,temp2+1,temp12));
    if(temp72!=INT_MAX){
       temp72=temp72+temp18;
    }
    temp72=min(temp72,print0(b,c,e+1,temp0,temp2,temp12));
    c[e][temp0][temp2]=temp72;
    return temp72;
}
int palindromePartition(string b,int c){
    int e=0;
    int temp0=0;
    int temp2=0;
    int temp12=0;
    int temp18=0;
    vector<vector<vector<int>>> temp28;
    for(int temp48=0;temp48<b.size();temp48++){
        vector<vector<int>> temp72;
        for(int temp78=0;temp78<b.size();temp78++){
            vector<int> temp92;
            for(int temp98=0;temp98<c;temp98++){
                temp92.push_back(-1);
            }
            temp72.push_back(temp92);
        }
        temp28.push_back(temp72);
    }
    int temp48=0;
    //temp12=-1;
    temp48=print0(b,temp28,e,temp12,temp2,c);
    return temp48;

}
};
56181