# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086299 | toast12 | Laugh Analysis (IOI16_laugh) | C++14 | 0 ms | 0 KiB |
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;
int main() {
string s;
cin >> s;
vector<int> pos;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'a' || s[i] == 'h')
pos.push_back(i);
}
int l = pos[0], r = pos[0];
int ans = 0;
int cur = 1;
while (r < s.length()) {
if (pos[cur]-r > 1) {
ans = max(ans, r-l+1);
l = r = pos[cur];
cur++;
}
else {
if (s[pos[cur]] == s[r]) {
ans = max(ans, r-l+1);
l = r = pos[cur];
cur++;
}
else {
r++;
ans = max(ans, r-l+1);
cur++;
}
}
}
cout << ans << '\n';
return 0;
}