Advertisement
jakaria_hossain

codeforce - email from polycarp

Jun 21st, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. string a,b,str;
  10. cin>>a>>b;
  11. int x=a.size(),y=b.size();
  12. if(y<x)cout<<"NO"<<endl;
  13. else
  14. {
  15. int i=0,j=0;
  16. bool f= false;
  17. while(i<x || j<y)
  18. {
  19. if(a[i]==b[j])
  20. {
  21. str+=b[j];
  22. i++,j++;
  23. }
  24. else
  25. {
  26. if(a[i-1]==b[j])
  27. j++;
  28. else
  29. {
  30. f=true;
  31. break;
  32. }
  33. }
  34. }
  35. if(f)cout<<"NO"<<endl;
  36. else if(str==a)cout<<"YES"<<endl;
  37. else cout<<"NO"<<endl;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement