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

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

Speed Typing

면접 대비

메모리 제한1024 MB

요약
목표 문자열 I가 입력된 문자열 P의 부분 수열인지 확인하고, 가능하면 삭제해야 하는 여분 글자 수를 구한다.
난이도

보통10점 중 4점

유형
투 포인터, 그리디
정답자
아직 제출이 없습니다

문제

Barbara is a speed typer. In order to check her typing speed, she performs a speed test. She is given a string II that she is supposed to type.

While Barbara is typing, she may make some mistakes, such as pressing the wrong key. As her typing speed is important to her, she does not want to spend additional time correcting the mistakes, so she continues to type with the errors until she finishes the speed test. After she finishes the speed test, she produces a PP.

Now she wonders how many extra letters she needs to delete in order to get II from PP. It is possible that Barbara made a mistake and PP cannot be converted back to II just by deleting some letters. In particular, it is possible that Barbara missed some letters.

Help Barbara find out how many extra letters she needs to remove in order to obtain II or if II cannot be obtained from PP by removing letters then output IMPOSSIBLE.

입력

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case has 22 lines. The first line of each test case is an input string II (that denotes the string that the typing test has provided). The next line is the produced string PP (that Barbara has entered).

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is the number of extra letters that need to be removed in order to obtain II. If it is not possible to obtain II then output IMPOSSIBLE as yy.

제한

  • 1≤T≤1001≤T≤100.
  • Both the strings contain letters from a-z and A-Z.
  • Length of the given strings will be 1≤∣I∣,∣P∣≤1051 ≤ |I|,|P| ≤ 10^5.

예제2

  1. 예제 1

    입력
    2
    aaaa
    aaaaa
    bbbbb
    bbbbc
    
    예상 출력
    Case #1: 1
    Case #2: IMPOSSIBLE
    
  2. 예제 2

    입력
    2
    Ilovecoding
    IIllovecoding
    KickstartIsFun
    kkickstartiisfun
    
    예상 출력
    Case #1: 2
    Case #2: IMPOSSIBLE