Advertisement
drof13

Untitled

Dec 8th, 2022
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <iterator>
  5. #include <map>
  6. #include <set>
  7. #include <string>
  8. #include <vector>
  9. #include <algorithm>
  10. #include <stack>
  11. #include <deque>
  12. #include <queue>
  13. #include <climits>
  14. #include <cstdio>
  15.  
  16. #define ll long long
  17. #define db double
  18. #define ff first
  19. #define ss second
  20. #define ll long long
  21.  
  22. // const int MOD = 1e9 + 7;
  23. const int MOD = 1e9 + 9;
  24. // const int INF = LONG_MAX;
  25. // const int INF = INT_MAX;
  26. const int INF = 10000000;
  27. const int P1 = 179;
  28. // const int P2 = 307;
  29. const int P2 = 257;
  30.  //const int MAXN = 4;
  31. const int MAXN = 1 << 17;
  32.  
  33.  
  34. using namespace std;
  35.  
  36. int main() {
  37.     ios_base::sync_with_stdio(0);
  38.     cin.tie(0);
  39.     cout.tie(0);
  40.     freopen("H:\\Downloads\\24 (1)\\24.txt", "r", stdin);
  41.     string s;
  42.     cin >> s;
  43.     int countA = 0;
  44.     int maxLen = 0;
  45.     int len = 0;
  46.     int lenLastF = 0;
  47.     for (int i = 0; i < s.size(); i++) {
  48.         if (len == 0 && s[i] == 'F') {
  49.             len = 1;
  50.         }
  51.         if (len != 0) {
  52.             if (s[i] == 'A') {
  53.                 countA++;
  54.                 if (countA == 3) {
  55.                     countA = 0;
  56.                     maxLen = max(maxLen, lenLastF);
  57.                     len = 0;
  58.                     lenLastF = 0;
  59.                 }
  60.                 else {
  61.                     len++;
  62.                 }
  63.             }
  64.             if (s[i] == 'F') {
  65.                 lenLastF = ++len;
  66.             }
  67.             else {
  68.                 len++;
  69.             }
  70.         }
  71.     }
  72.     cout << maxLen;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement