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>
#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
using namespace std;
/* ------------------------ hi lol ------------------------ */
int longest_laugh(string s) {
int slen=s.length();
int ans=0,cur=0;
if (s[0]=='h'||s[0]=='a') {
cur++;
ans++;
}
for (int i=1;i<slen;i++) {
if ((s[i]=='a'&&s[i-1]=='h')||(s[i]=='h'&&s[i-1]=='a')) {
cur++;
}
else if ((s[i]=='a')||(s[i]=='h')) {
cur=1;
}
ans=max(ans,cur);
}
return ans;
}
/*
int main() {
cout << longest_laugh("ahaha") << endl;
cout << longest_laugh("ahahrunawayahahsofasthah") << endl;
cout << longest_laugh("ahahaahaha") << endl;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |