Submission #21807

# Submission time Handle Problem Language Result Execution time Memory
21807 2017-04-25T21:47:43 Z sampriti Laugh Analysis (IOI16_laugh) C++14
Compilation error
0 ms 0 KB
#include "laugh.h"

#include <algorithm>
#include <string>

using namespace std;

int longest_laugh(const 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;
}

Compilation message

/tmp/ccUHvHo6.o: In function `main':
grader.cpp:(.text.startup+0xb3): undefined reference to `longest_laugh(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status