Advertisement
Saleh127

Live ar 6901

Jan 24th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12.  
  13.  
  14. string a,b;
  15. ll i,j,k,l=0,m,n;
  16. cin>>a>>b;
  17.  
  18. for(i=0,j=0;i<a.size() && j<b.size();i++,j++)
  19. {
  20. while(a[i]!='a' && i<a.size())
  21. {
  22. i++;
  23. }
  24. while(b[j]!='a' && j<b.size())
  25. {
  26. j++;
  27. }
  28. l+=abs(i-j);
  29. }
  30.  
  31. cout<<l<<endl;
  32. }
  33.  
  34.  
  35.  
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement