DPL_1_E レーベンシュタイン距離
目次
# 問題
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E&lang=ja#
# 解説
TODO
# 計算量
# 解答
#define MAX_S 1001
string S1, S2;
Int dp[MAX_S][MAX_S];
void input() {
cin >> S1 >> S2;
}
void solve() {
loop(c1,0,S1.length()+1) {
loop(c2,0,S2.length()+1) {
if (c1 == 0) dp[c1][c2] = c2;
else if (c2 == 0) dp[c1][c2] = c1;
else if (S1[c1-1] == S2[c2-1]) {
dp[c1][c2] = dp[c1-1][c2-1];
} else {
dp[c1][c2] = 1 + min(min(dp[c1-1][c2], dp[c1][c2-1]), dp[c1-1][c2-1]);
}
}
}
cout << dp[S1.length()][S2.length()] << endl;
}
int main() {
input();
solve();
}