hiho week 162 register

Ended

Participants:319

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-11 15:43:57

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
23
24
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
char str[maxn];
int dp[maxn][maxn];
int main()
{
  while(~scanf("%s",str)){
    int len = strlen(str);
    
    for( int i = len-1; i >= 0; i-- ){
      for( int j = i + 1; j < len; j++ ){
        if(str[i] == str[j]){
          dp[i][j] = dp[i+1][j-1];
        }
        else {
          dp[i][j] = min(dp[i+1][j],min(dp[i][j-1],dp[i+1][j-1])) + 1;
        }
      }
    }
    printf("%d\n",dp[0][len-1]);
  }
  return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX