I. Laughing Out Loud

Codeforces
IDCF10058I
Time1000ms
Memory512MB
Difficulty
English · Original
Formal · Original
Little Toojee was a happy go lucky boy. He seemed to find most, if not all, things funny. One day he read a word and started laughing a lot. Turns out that the word consisted only of the letters L and O. Whenever he saw the subsequence ‘LOL’ in the word, he laughed for 1 second. Given t strings, find out for how long Toojee laughed on seeing each string. The first line contains t queries. This is followed by t lines each containing one string S. String S consists only of capital alphabets. Output for each string on a new line. *Constraints* Test1: On observation, we can tell that there is only 1 occurrence of LOL. Test2: Let the string be 0-indexed and let V = {a, b, c} denote the indices that make up the string “LOL”, where a is index of the 1st ‘L’, b is index of the ‘O’ and c is the index of the 2nd ‘L’. So, V can be {0, 1, 2}, {2, 3, 4}, {0, 1, 4} and {0, 3, 4}. We see that there are 4 occurrences of the string “LOL”. ## Input The first line contains t queries. This is followed by t lines each containing one string S. String S consists only of capital alphabets. ## Output Output for each string on a new line.*Constraints* 1  ≤  t  ≤  10 1  ≤  |S|  ≤  105 [samples] ## Note Test1: On observation, we can tell that there is only 1 occurrence of LOL.Test2: Let the string be 0-indexed and let V = {a, b, c} denote the indices that make up the string “LOL”, where a is index of the 1st ‘L’, b is index of the ‘O’ and c is the index of the 2nd ‘L’. So, V can be {0, 1, 2}, {2, 3, 4}, {0, 1, 4} and {0, 3, 4}. We see that there are 4 occurrences of the string “LOL”.
**Definitions** Let $ t \in \mathbb{Z} $ be the number of test cases. Let $ S_1, S_2, \dots, S_t $ be strings over the alphabet $ \{ \text{A}, \text{B}, \dots, \text{Z} \} $. **Constraints** 1. $ 1 \le t \le \text{some upper bound (not specified)} $ 2. Each string $ S_k $ consists only of uppercase English letters. **Objective** For each string $ S_k $, count the number of subsequences equal to "LOL", i.e., the number of triples of indices $ (i, j, l) $ such that: - $ i < j < l $, - $ S_k[i] = \text{'L'} $, - $ S_k[j] = \text{'O'} $, - $ S_k[l] = \text{'L'} $. Output the count for each $ S_k $.
API Response (JSON)
{
  "problem": {
    "name": "I. Laughing Out Loud",
    "description": {
      "content": "Little Toojee was a happy go lucky boy. He seemed to find most, if not all, things funny. One day he read a word and started laughing a lot. Turns out that the word consisted only of the letters L and",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10058I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Little Toojee was a happy go lucky boy. He seemed to find most, if not all, things funny. One day he read a word and started laughing a lot. Turns out that the word consisted only of the letters L and...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ t \\in \\mathbb{Z} $ be the number of test cases.  \nLet $ S_1, S_2, \\dots, S_t $ be strings over the alphabet $ \\{ \\text{A}, \\text{B}, \\dots, \\text{Z} \\} $.\n\n**Constraints**  \n1....",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments