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; }
|