Submission #21810

#TimeUsernameProblemLanguageResultExecution timeMemory
21810sampritiLaugh Analysis (IOI16_laugh)C++14
100 / 100
3 ms2336 KiB
#include "laugh.h"
 
#include <algorithm>
#include <string>
 
using namespace std;
 
int longest_laugh(std::string S) {
  int ans = 0;
  int curr = 0;
  if(S[0] == 'h' || S[0] == 'a') curr++;
  for(int i = 1; i < (int)S.length(); i++) {
    if(S[i] == 'h') {
      if(S[i - 1] == 'a') curr++;
      else curr = 1;
    }
    else if(S[i] == 'a') {
      if(S[i - 1] == 'h') curr++;
      else curr = 1;
    }
    else {
      curr = 0;
    }
    ans = max(ans, curr);
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...