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;
using i64 = long long;
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
int longest_laugh(string s) {
int N = s.size(), ans = 0;
for (int i = 0; i < N;) {
if (s[i] != 'a' && s[i] != 'h') {
i++;
continue;
}
int j = i;
while (j + 1 < N && ((s[j + 1] == 'a' && s[j] == 'h') || (s[j + 1] == 'h' && s[j] == 'a')))
j++;
ans = max(ans, j - i + 1);
if(i == j) i++;
else i = j;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |