Advertisement
artemgf

Министерство правды

Dec 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <set>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <stdio.h>
  8. #include <cmath>
  9. #include <math.h>
  10. #include <queue>
  11. #include <stack>
  12. #include <climits>
  13. #include <deque>
  14. #include <ctime>
  15.  
  16. using namespace std;
  17.  
  18. typedef long long ll;
  19. typedef unsigned long long ull;
  20. typedef unsigned int ui;
  21.  
  22. int main()
  23. {
  24.     string s;
  25.     getline(cin, s);
  26.    
  27.     string y;
  28.     string u = s;
  29.     queue<pair<int, int>>next;
  30.     ll last;
  31.     cin >> y;
  32.     ll i = -1;
  33.     i = s.find(y);
  34.     if (i == 4294967295)
  35.         return cout << "I HAVE FAILED!!!", 0;
  36.     next.push({ i, i + y.size()-1});
  37.     last = i + y.size() - 1;
  38.     while (cin >> y)
  39.     {
  40.         i = s.substr(last+2,s.size()-last-2).find(y);
  41.         if (i == 4294967295)
  42.             return cout << "I HAVE FAILED!!!", 0;
  43.         else
  44.             i += last + 2;
  45.         next.push({ i, i+y.size()-1 });
  46.         last = i + y.size() - 1;
  47.     }
  48.  
  49.     for (int i = 0; i < s.size(); i++)
  50.     {
  51.         if (!next.empty())
  52.             if (i >= next.front().first&&i <= next.front().second)
  53.             {
  54.                 cout << s[i];
  55.                 if (i + 1 > next.front().second)
  56.                     next.pop();
  57.             }
  58.             else
  59.             {
  60.                 if (s[i] != ' ')
  61.                     cout << "_";
  62.                 else
  63.                     cout << s[i];
  64.             }
  65.         else
  66.         {
  67.             if (s[i] != ' ')
  68.                 cout << "_";
  69.             else
  70.                 cout << s[i];
  71.         }
  72.     }
  73.     system("pause");
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement