L. Emoticons

Codeforces
IDCF10079L
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Bob has received a text message from his girlfriend Alice. The message consists only of colons ("_:_") and brackets ("_(_" and "_)_"). Two consecutive characters in the message form an emoticon if one of them is a colon and the other one is a bracket. If the bracket's inner side faces the colon, the emoticon is a smiley; otherwise it is a frowney. So, "_:)_" and "_(:_" are smilies, and "_:(_" and "_):_" are frownies. One character can belong to two emoticons: for example, there are both a smiley and a frowney in the message "_):)_". Unfortunately, Bob has trouble understanding the message. He can only find out Alice's mood based on the number of emoticons in the message: Help Bob determine how does Alice feel! The first line contains a single integer n, the length of the message (1 ≤ n ≤ 105). The next line contains the message, a string consisting of n characters. Each of the characters is either "_:_", "_(_" or "_)_". In a single line, output either "_HAPPY_", "_BORED_" or "_SAD_" corresponding to Alice's mood. ## Input The first line contains a single integer n, the length of the message (1 ≤ n ≤ 105). The next line contains the message, a string consisting of n characters. Each of the characters is either "_:_", "_(_" or "_)_". ## Output In a single line, output either "_HAPPY_", "_BORED_" or "_SAD_" corresponding to Alice's mood. [samples]
**Definitions** Let $ n \in \mathbb{Z} $ be the length of the message. Let $ s = s_1 s_2 \dots s_n $ be a string over the alphabet $ \{ \texttt{:}, \texttt{(}, \texttt{)} \} $. **Constraints** $ 1 \le n \le 10^5 $ **Definitions (Emoticons)** For each $ i \in \{1, \dots, n-1\} $, the pair $ (s_i, s_{i+1}) $ forms an emoticon if one character is `:` and the other is `(` or `)`. - It is a **smiley** if: $ (s_i, s_{i+1}) = (\texttt{:}, \texttt{)}) $ or $ (s_i, s_{i+1}) = (\texttt{(}, \texttt{:}) ) $ - It is a **frowney** if: $ (s_i, s_{i+1}) = (\texttt{:}, \texttt{(}) $ or $ (s_i, s_{i+1}) = (\texttt{)}, \texttt{:}) ) $ Let: - $ H = \# \{ i \in \{1, \dots, n-1\} \mid (s_i, s_{i+1}) \text{ is a smiley} \} $ - $ F = \# \{ i \in \{1, \dots, n-1\} \mid (s_i, s_{i+1}) \text{ is a frowney} \} $ **Objective** Output: - $ \texttt{HAPPY} $ if $ H > F $ - $ \texttt{SAD} $ if $ H < F $ - $ \texttt{BORED} $ if $ H = F $
API Response (JSON)
{
  "problem": {
    "name": "L. Emoticons",
    "description": {
      "content": "Bob has received a text message from his girlfriend Alice. The message consists only of colons (\"_:_\") and brackets (\"_(_\" and \"_)_\"). Two consecutive characters in the message form an emoticon if one",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10079L"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Bob has received a text message from his girlfriend Alice. The message consists only of colons (\"_:_\") and brackets (\"_(_\" and \"_)_\"). Two consecutive characters in the message form an emoticon if one...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the length of the message.  \nLet $ s = s_1 s_2 \\dots s_n $ be a string over the alphabet $ \\{ \\texttt{:}, \\texttt{(}, \\texttt{)} \\} $.\n\n**Constraints**  \n...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments