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>
#include "laugh.h"
using namespace std;
int longest_laugh(string s){
int n = s.length();
char lastchar = '-';
int clen = 0;
int mlen = 0;
for (int i=0; i<n; i++){
if (clen == 0){
if (s[i] == 'a' || s[i] == 'h'){
lastchar = s[i];
clen = 1;
}
}
else{
if (lastchar == 'a'){
if (s[i] == 'h'){ clen++; lastchar = s[i];}
else if (s[i] == 'a'){ clen=1; lastchar=s[i];}
else{ lastchar = '-'; clen = 0;}
}
else if (lastchar == 'h'){
if (s[i] == 'a'){ clen++; lastchar = s[i];}
else if (s[i] == 'h'){ clen=1; lastchar=s[i];}
else{lastchar = '-'; clen=0;}
}
}
mlen = max(clen,mlen);
}
return mlen;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |