Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(){
- string x, y;
- cin >> x >> y;
- vector<vector<int> > dp(x.size()+1, vector<int>(y.size()+1, INF));
- REP(i, x.size()) dp[i][0]=i;
- REP(i, y.size()) dp[0][i]=i;
- FOR(i, 1, x.size()+1){
- FOR(j, 1, y.size()+1){
- int tmp=dp[i-1][j-1];
- if(x[i-1]!=y[j-1]) tmp++;
- dp[i][j]=min(tmp, min(dp[i-1][j]+1, dp[i][j-1]+1));
- }
- }
- cout << dp[x.size()][y.size()] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement