[Kick Start 2022 Round A] Speed Typing

Kick Start 2022 Round A 2022 Speed Typing

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
#include <bits/stdc++.h>
using namespace std;
string solve(string& origin, string& problem) {
if(problem.length() < origin.length()) return "IMPOSSIBLE";
int i = 0, j = 0;
while(i < origin.length() and j < problem.length()) {
if(origin[i] == problem[j]) {
i++;j++;
} else {
j++;
}
}
if(i == origin.length()) {
return to_string(problem.length() - origin.length());
}
return "IMPOSSIBLE";
}
int main() {
int t;
cin>>t;
for(int i = 1; i <= t; i++) {
string o, p;
cin>>o>>p;
cout<<"Case #"<<i<<": "<< solve(o,p)<<endl;
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/03/20/PS/Google/speed-typing/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.