Submission #898359

# Submission time Handle Problem Language Result Execution time Memory
898359 2024-01-04T14:19:57 Z devkudawla Laugh Analysis (IOI16_laugh) C++17
Compilation error
0 ms 0 KB
#define ll  int
int longest_laugh(string s){

        ll n = s.size();
        vector<ll> dp(n, 0);
        if (s[0] == 'h' or s[0] == 'a')
            dp[0] = 1;
        ll answer = 0;
        for (ll i = 1; i < n; i++)
        {
            if (s[i] == 'h' or s[i] == 'a')
            {
                dp[i] = 1;
                if ((s[i] == 'h' and s[i - 1] == 'a') or (s[i] == 'a' and s[i - 1] == 'h'))
                    dp[i] = max(dp[i], dp[i - 1] + dp[i]);
            }
            answer = max(answer, dp[i]);
        }

      return answer;
}

Compilation message

laugh.cpp:2:19: error: 'string' was not declared in this scope
    2 | int longest_laugh(string s){
      |                   ^~~~~~