Advertisement
deushiro

Untitled

Mar 1st, 2020
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <string>
  6. #include <set>
  7. #include <map>
  8. #include <list>
  9. #include <time.h>
  10. #include <math.h>
  11. #include <random>
  12. #include <deque>
  13. #include <queue>
  14. #include <cassert>
  15. #include <unordered_map>
  16. #include <unordered_set>
  17. #include <iomanip>
  18. #include <bitset>
  19. #include <sstream>
  20. #include <chrono>
  21. #include <cstring>
  22. #include <string>
  23.  
  24. using namespace std;
  25.  
  26. #define X first
  27. #define Y second
  28. #define pb push_back
  29. #define mp make_pair
  30. #define sz(x) ((int)(x).size())
  31. #define all(x) (x).begin(),(x).end()
  32. #define PI 3.14159265358979323846
  33.  
  34. typedef long long ll;
  35.  
  36. const int maxn = 1e5 + 228;
  37. const int mod = 1e9 + 7;
  38.  
  39.  
  40.  
  41. int main() {
  42.     ios_base::sync_with_stdio(false);
  43.     cin.tie(0);
  44.     cout.tie(0);
  45.     int n;
  46.     cin >> n;
  47.     string s;
  48.     cin >> s;
  49.     int res = 0;
  50.     while(true){
  51.         int l = -1;
  52.         int r = -1;
  53.         int maxi = 1;
  54.         int ans = 1;
  55.         cout << s << endl;
  56.         for(int i = 1; i < s.size(); ++i){
  57.             if(s[i] - s[i - 1] == 1)
  58.                 ans++;
  59.             else{
  60.                 if(ans > maxi){
  61.                     r = i - 1;
  62.                     l = i - ans;
  63.                     maxi = ans;
  64.                 }
  65.             }
  66.         }
  67.         cout << l << " " << r << endl;
  68.         string xd = "";
  69.         if(l == -1)
  70.             break;
  71.         res += maxi - 1;
  72.         for(int i = 0; i < s.size(); ++i){
  73.             if(i > l && i <= r)
  74.                 continue;
  75.             else
  76.                 xd += s[i];
  77.         }
  78.     }
  79.     cout << res << endl;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement