Submission #20588

#TimeUsernameProblemLanguageResultExecution timeMemory
20588model_codeLaugh Analysis (IOI16_laugh)C++14
100 / 100
3 ms2336 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...