/
BOJ_24839.java
31 lines (30 loc) · 1.07 KB
/
BOJ_24839.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
private void solution() throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tc = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for (int t = 1; t <= tc; t++) {
String from = br.readLine();
String to = br.readLine();
int pt = 0;
boolean chk = false;
for (int i = 0; i < from.length(); i++) {
chk = false;
while (pt < to.length()) {
if (to.charAt(pt++) == from.charAt(i)) {
chk = true;
break;
}
}
if (!chk) break;
}
sb.append(String.format("Case #%d: ", t)).append(!chk?"IMPOSSIBLE":to.length()-from.length()).append('\n');
}
System.out.print(sb);
}
public static void main(String[] args) throws Exception {
new Main().solution();
}
}