Submission #569027

#TimeUsernameProblemLanguageResultExecution timeMemory
569027Aurora2005Laugh Analysis (IOI16_laugh)C++14
100 / 100
5 ms604 KiB
#include<bits/stdc++.h>
using namespace std;

int longest_laugh(string s){
  int N = s.size();
  int now=0,ans=0;
  char c;
  for(int i=0;i<N;i++){
    if(s[i] == 'a'){
      if(now == 0){
        now++;
        c = 'a';
      }
      else if(c == 'a'){
        now = 1;
      }
      else{
        now++;
        c = 'a';
      }
    }
    else if(s[i] == 'h'){
      if(now == 0){
        now++;
        c = 'h';
      }
      else if(c == 'h'){
        now = 1;
      }
      else{
        now++;
        c = 'h';
      }
    }
    else{
      now = 0;
    }
    ans = max(ans,now);
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...