Submission #939393

# Submission time Handle Problem Language Result Execution time Memory
939393 2024-03-06T10:21:07 Z KK_1729 Laugh Analysis (IOI16_laugh) C++17
Compilation error
0 ms 0 KB
#include "laugh.h"
#include <bits/stdc++.h>
using namespace std;
int longest_laugh(string s)
{
    int n = s.size();
    vector<int> dp(n);
    if (s[0] == 'h' || s[0] == 'a') dp[0] = 1;
    FOR(i,0,n){
      if (s[i] == 'h'){
        if (s[i-1] == 'a') dp[i] = dp[i-1]+1;
      }
      if (s[i] == 'a'){
        if (s[i-1] == 'h') dp[i] = dp[i-1]+1;
      }
    }
    int ans = 0;
    for (auto x: dp) ans = max(ans, x);

    return ans;
}

Compilation message

laugh.cpp: In function 'int longest_laugh(std::string)':
laugh.cpp:9:9: error: 'i' was not declared in this scope
    9 |     FOR(i,0,n){
      |         ^
laugh.cpp:9:5: error: 'FOR' was not declared in this scope
    9 |     FOR(i,0,n){
      |     ^~~