hiho week 162 register

Ended

Participants:319

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-06 20:01:01

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int dp[105][105];
char str[105];
int solve(int l,int r){
    int& ans = dp[l][r];
    if( l>=r ) return ans = 0;
    if( ans ) return ans;
    if( str[l]==str[r] ) return ans = solve(l+1,r-1);
    return ans = min(solve(l+1,r),min(solve(l,r-1),solve(l+1,r-1)))+1;
}
int main(){
    cin >> str;
    cout << solve(0,strlen(str)-1) << endl;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX