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>
using namespace std;
#define int long long
int longest_laugh(string s){
int cur= 0, ans=0,prev=2,n=s.size();
// bool rn = true;
if (s[0] == 'h'){
cur = 1;
ans = 1;
prev = 1;
}
if (s[0] == 'a'){
cur = 1;
ans = 1;
prev = 0;
}
for (int i = 1; i < n; i++){
if (prev == 1 && s[i] == 'a'){
cur++;
ans = max(ans,cur);
prev = 0;
}
else if (prev == 0 && s[i] == 'h'){
cur++;
ans = max(ans,cur);
prev = 1;
}
else {
cur = 0;
prev = 2;
}
}
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... |