아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Sperhling

시간 제한1초메모리 제한1024 MB

요약
커서가 끝에 있는 상태에서 잘못 입력한 문자열을 목표 문자열로 바꾸는 데 필요한 최소 키 입력 횟수를 구한다.
난이도

보통10점 중 6점

유형
동적 계획법, 문자열, 구현
정답자
아직 제출이 없습니다

문제

On her spare time Caitlin loves to do speed typing. Unfortunately Caitlyn was never good at spelling. So what often happens is that Catelin makes a mistake spelling a word, and has to go back and fix her typo. One word in particular that Caitlynn has a hard time spelling is the word mischievous. Catelyn usually spells it mischevious instead. In order to fix this typo, Caytlin needs to do 12 key presses.

Katelin thinks that no matter how much time she puts into speed typing, she will always make mistakes. But maybe she can get better at quickly fixing her mistakes. Katelyn would like you to help her with this.

Suppose that Caytlyn has just written the word S_1S\_1, but that she should have written S_2S\_2. Assume that the cursor is initially at the end of S_1S\_1, and that after fixing the typo, Caitlin needs to place the cursor at the end of S_2S\_2. Output the fewest number of key presses needed to make S_1S\_1 into S_2S\_2.

The keys you are allowed to use are

  • the left and right arrow keys.
  • the back space key.
  • the keys ‘a‘,…,‘z‘`a`, \ldots, `z`.

You are not allowed to press back space or the left arrow key when the cursor is all the way to the left. You are also not allowed to press the right arrow key when the cursor is all the way to the right.

입력

The first two lines contain the strings S_1S\_1 respectively S_2S\_2. Both S_1S\_1 and S_2S\_2 consist only of lowercase English letters, and are between 11 and 100100 characters long.

출력

Output a single line with the fewest number of key presses needed to make S_1S\_1 into S_2S\_2.

예제3

  1. 예제 1

    입력
    mischevious
    mischievous
    
    예상 출력
    12
    
  2. 예제 2

    입력
    cerstermergerd
    customer
    
    예상 출력
    20
    
  3. 예제 3

    입력
    caitlin
    caitlynn
    
    예상 출력
    5