시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 113 | 52 | 36 | 38.298% |
Russian scientists are working on several promising topics. One of them is the quality of laugh. In this research they analyse the human speech and extract the laugh from it.
The scientists already made the software which converts speech to text. They consider a string of alternating letters “h
” and “a
” to be a laugh. For example, strings “ahahaha
”, “hah
” and “a
” are laughs, but “abacaba
” and “h
h” are not.
You are given a string s containing the text. Find the length of the longest substring which is considered a laugh.
You should implement the following function (method):
int longest_laugh(string s).
This function should return the length of the longest substring of s which is considered a laugh.Please use the provided template files for details of implementation in your programming language.
ahaha
”The whole string is a laugh, so the answer is 5.
ahahrunawayahahsofasthah
”The longest substring is “ahah
”, so the answer is 4.
ahahaahaha
”The longest substring is “ahaha
”, so the answer is 5.
번호 | 배점 | 제한 |
---|---|---|
1 | 21 | |s| ≤ 20 |
2 | 26 | |s| ≤ 5000 |
3 | 53 | |s| ≤ 105 |
The sample grader reads the input in the following format:
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)