Submission #1086306

#TimeUsernameProblemLanguageResultExecution timeMemory
1086306toast12Laugh Analysis (IOI16_laugh)C++17
100 / 100
3 ms700 KiB
#include "laugh.h"
#include <vector>
#include <string>
using namespace std;

int longest_laugh(string s)
{
    int ans = 0;
    int temp = 0;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            if (i != 0 && s[i-1] == 'h')
                temp++;
            else
                temp = 1;
        }
        else if (s[i] == 'h') {
            if (i != 0 && s[i-1] == 'a')
                temp++;
            else
                temp = 1;
        }
        else temp = 0;
        ans = max(ans, temp);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...