Logo
(追記) (追記ここまで)

24839번 - Speed Typing 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB35519914857.812%

문제

Barbara is a speed typer. In order to check her typing speed, she performs a speed test. She is given a string $I$ 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 $P$.

Now she wonders how many extra letters she needs to delete in order to get $I$ from $P$. It is possible that Barbara made a mistake and $P$ cannot be converted back to $I$ 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 $I$ or if $I$ cannot be obtained from $P$ by removing letters then output IMPOSSIBLE.

입력

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

Each test case has 2ドル$ lines. The first line of each test case is an input string $I$ (that denotes the string that the typing test has provided). The next line is the produced string $P$ (that Barbara has entered).

출력

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

제한

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

Test Set 1 (5점)

시간 제한: 20 초

All letters in $I$ are the same.

Test Set 2 (9점)

시간 제한: 40 초

예제 입력 1

2
aaaa
aaaaa
bbbbb
bbbbc

예제 출력 1

Case #1: 1
Case #2: IMPOSSIBLE

In the first test case, $P$ contains one extra a, so she needs to remove 1ドル$ extra letter in order to obtain $I$.

In the second test case, Barbara typed only 4ドル$ letters b, while $I$ consists of 5ドル$ letters b so the answer is IMPOSSIBLE.

예제 입력 2

2
Ilovecoding
IIllovecoding
KickstartIsFun
kkickstartiisfun

예제 출력 2

Case #1: 2
Case #2: IMPOSSIBLE

In the first test case, $P$ has 2ドル$ extra letters, I and l. The other letters are in the order given in $I$. So she needs to remove 2ドル$ letters in order to obtain $I$.

In the second test case, there is no letter K in $P$ so the answer is IMPOSSIBLE.

힌트

출처

Contest > Google > Kick Start > Google Kick Start 2022 > Round A A번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /