This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e6 + 5;
int N;
vector<int> g[MX];
bool type[MX];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
string s;
cin >> s;
N = s.size();
vector<int> v;
int m = 0;
for(int i = 0; i < N; i++) {
// cout << i << " " << s[i] << '\n';
if(s[i] == '?') {
i++;
m++;
continue;
}
if(s[i] != 'm') continue;
if(s[i + 1] == 'a') {
v.push_back(1);
i += 3;
} else {
v.push_back(0);
i += 3;
}
}
// cout << '\n';
reverse(v.begin(), v.end());
int l = 1, r = m;
for(auto x : v) {
if(x) {
l++;
r = m;
} else {
r--;
l = 1;
}
// cout << l << " " << r << " " << x << '\n';
}
cout << r - l + 1 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |