Advertisement
myloyo

i задача

Jul 6th, 2023 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <algorithm>
  6. #include <set>
  7. #include <list>
  8. #include <sstream>
  9. #include <vector>
  10. #include <map>
  11. #include <stdlib.h>
  12.  
  13. using namespace std;
  14. ifstream in("input.txt");
  15. ofstream out("output.txt");
  16.  
  17.  
  18. int main() {
  19. int n;
  20. cin >> n;
  21. string h;
  22. string* p = new string[n];
  23. string* pc = new string[n];
  24. for (int i = 0; i < n; i++) {
  25. cin >> h;
  26. p[i] = h;
  27. cin >> h;
  28. pc[i] = h;
  29. }
  30.  
  31. for (int i = 0; i < n; i++) {
  32. string a = p[i];
  33. string b = pc[i];
  34. bool f = false;
  35. int minim = 1000000000000;
  36. int maxim = -100000000000;
  37. int j = a.length() - b.length();
  38. while (b.find(a[0]) && !a.empty()) {
  39. int x = b.find(a[0]);
  40. minim = min(minim, x);
  41. maxim = max(maxim, x);
  42. b.erase(b.find(a[0]));
  43. a.erase(0);
  44. f = true;
  45. }
  46. if (f) {
  47. cout << "YES" << endl;
  48. }
  49. else {
  50. cout << "NO" << endl;
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement