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 <string>
#include "laugh.h"
int longest_laugh(std::string s)
{
int cur = 0, ans = 0;
if (s[0] == 'a' || s[0] == 'h')
cur++;
for (int i = 1; i < (int)s.size(); i++)
{
if ((s[i - 1] == 'a' && s[i] == 'h') || (s[i - 1] == 'h' && s[i] == 'a'))
cur++;
else
{
ans = std::max(ans, cur);
cur = 0;
if (s[i] == 'a' || s[i] == 'h')
cur++;
}
}
ans = std::max(ans, cur);
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... |