fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int t, cnt, i, j;
  8. char m[25002], w[25002];
  9. scanf("%d", &t);
  10. while(t--) {
  11. cnt=0; i=j=0;
  12. scanf("%s%s", m, w);
  13. if(strlen(m)<strlen(w)) {
  14. for(; i<strlen(m); i++) {
  15. for(; j<strlen(w); j++) {
  16. if(m[i]==w[j]) {
  17. cnt++;
  18. j++;
  19. break;
  20. }
  21. }
  22. }
  23. if(cnt==strlen(m)) printf("YES\n");
  24. else printf("NO\n");
  25. }
  26. else {
  27. for(; i<strlen(w); i++) {
  28. for(; j<strlen(m); j++) {
  29. if(w[i]==m[j]) {
  30. cnt++;
  31. j++;
  32. break;
  33. }
  34. }
  35. }
  36. if(cnt==strlen(w)) printf("YES\n");
  37. else printf("NO\n");
  38. }
  39. }
  40. return 0;}
Success #stdin #stdout 0s 3300KB
stdin
1
abc axxb
stdout
NO