Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--){
- string s;
- cin>>s;
- string p;
- cin>>p;
- int n=s.length();
- int m=p.length();
- int ans=n+m;
- for(int i=0;i<m;i++){
- int ind=i;
- for(int j=0;j<n;j++){
- if(ind<m && s[j] == p[ind]) ind++;
- }
- ans=min(ans,n+m-ind+i);
- }
- cout<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement