Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <bits/stdc++.h>
  4. #define Nmax 1000005
  5. #define fs first
  6. #define sc second
  7. #define mk make_pair
  8. #define MOD 998244353
  9. #define INF 0x3f3f3f3f
  10. #define ll long long
  11.  
  12. using namespace std;
  13.  
  14. ifstream f("1.in");
  15.  
  16. int t;
  17. char s1[Nmax], s2[Nmax];
  18.  
  19. bool match(char a[], char b[])
  20. {
  21. int l1=strlen(a), l2=strlen(b);
  22. //cout << '\n';
  23. int i1=0, i2=0;
  24.  
  25. while (i1 < l1 && i2 < l2)
  26. {
  27. int eq=1;
  28. while (i1+1<l1 && a[i1] == a[i1+1])
  29. {
  30. i1++;
  31. eq++;
  32. }
  33.  
  34. int cnt=0;
  35. while (i2 < l2 && a[i1] == b[i2])
  36. {
  37. i2++;
  38. cnt++;
  39. }
  40. i1++;
  41. if (cnt < eq) return 0;
  42. }
  43.  
  44. if (i1<l1) return 0;
  45. while (i2<l2)
  46. {
  47. if (b[i2]!=a[l1-1]) return 0;
  48. i2++;
  49. }
  50. return 1;
  51. }
  52.  
  53. int main()
  54. {
  55. cin >> t;
  56. //t=1;
  57. while (t--)
  58. {
  59. cin >> s1 >> s2;
  60.  
  61. if (match(s1, s2) == true) cout << "YES\n";
  62. else cout << "NO\n";
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement