-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSpeed Typing.cpp
42 lines (37 loc) · 957 Bytes
/
Speed Typing.cpp
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
32
33
34
35
36
37
38
39
40
41
42
// Problem Link : https://codingcompetitions.withgoogle.com/kickstart/round/00000000008cb33e/00000000009e7021
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int z = 1; z <= t; z++){
string str1,str2;
cin >> str1 >> str2;
bool possible = true;
int j = 0;
int ans = 0;
for(int i = 0; i < str1.length(); i++){
while(j < str2.length() && str1[i] != str2[j]){
j++;
ans++;
}
if(j >= str2.length()){
possible = false;
break;
}
j++;
}
ans += str2.length()-j;
cout << "Case #" << z << ": ";
if(possible){
cout << ans << endl;
}else{
cout << "IMPOSSIBLE" << endl;
}
}
return 0;
}