Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iostream>
- #include <iterator>
- #include <map>
- #include <set>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <climits>
- #include <cstdio>
- #define ll long long
- #define db double
- #define ff first
- #define ss second
- #define ll long long
- // const int MOD = 1e9 + 7;
- const int MOD = 1e9 + 9;
- // const int INF = LONG_MAX;
- // const int INF = INT_MAX;
- const int INF = 10000000;
- const int P1 = 179;
- // const int P2 = 307;
- const int P2 = 257;
- //const int MAXN = 4;
- const int MAXN = 1 << 17;
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- freopen("H:\\Downloads\\24 (1)\\24.txt", "r", stdin);
- string s;
- cin >> s;
- int countA = 0;
- int maxLen = 0;
- int len = 0;
- int lenLastF = 0;
- for (int i = 0; i < s.size(); i++) {
- if (len == 0 && s[i] == 'F') {
- len = 1;
- }
- if (len != 0) {
- if (s[i] == 'A') {
- countA++;
- if (countA == 3) {
- countA = 0;
- maxLen = max(maxLen, lenLastF);
- len = 0;
- lenLastF = 0;
- }
- else {
- len++;
- }
- }
- if (s[i] == 'F') {
- lenLastF = ++len;
- }
- else {
- len++;
- }
- }
- }
- cout << maxLen;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement