169. SOS

Codeforces
IDCF10269169
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Morse code, developed in 1837, along with the invention of the telegram, was a revolutionary invention that struck a new frontier in the subject of telecommunications. Through a series of electrical pulses, messages could be sent to far distances through a series of dots and dashes, and at a speed that was unheard of before its invention. Since then, telegrams and Morse code have been essential in the realm of communications, especially in its role in the military, where fighter pilots were required to memorize Morse code until the 1990s. Your job is to create a translator that will take in messages encode it in morse, and output the result in alphabet form. You will receive a message, encoded in morse, whose dashes are represented by _-_, and dots represented by _._ Assume all letters will be uppercase. Each word will be separated via _/_, and each character will be separated by a space. Print out the complete translated statement. ## Input You will receive a message, encoded in morse, whose dashes are represented by _-_, and dots represented by _._ Assume all letters will be uppercase. Each word will be separated via _/_, and each character will be separated by a space. ## Output Print out the complete translated statement. [samples]
**Definitions** Let $ M $ be a string representing a Morse-encoded message, where: - Dots are denoted by `.` - Dashes are denoted by `-` - Characters within a word are separated by a single space ` ` - Words are separated by `/` Let $ \mathcal{M} : \{A, B, \dots, Z\} \to \{\text{dot-dash sequences}\} $ be the standard Morse code mapping for uppercase English letters. **Constraints** 1. All encoded letters are uppercase. 2. Input string $ M $ is well-formed: no leading/trailing spaces, no consecutive spaces or slashes except as separators. **Objective** Decode $ M $ into plaintext by: 1. Splitting $ M $ by `/` to obtain words. 2. For each word, splitting by ` ` to obtain individual Morse characters. 3. Mapping each Morse character to its corresponding letter using $ \mathcal{M}^{-1} $. 4. Joining letters into words, and words into a single string separated by spaces. Output the resulting decoded string.
API Response (JSON)
{
  "problem": {
    "name": "169. SOS",
    "description": {
      "content": "Morse code, developed in 1837, along with the invention of the telegram, was a revolutionary invention that struck a new frontier in the subject of telecommunications. Through a series of electrical p",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269169"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Morse code, developed in 1837, along with the invention of the telegram, was a revolutionary invention that struck a new frontier in the subject of telecommunications. Through a series of electrical p...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ M $ be a string representing a Morse-encoded message, where:  \n- Dots are denoted by `.`  \n- Dashes are denoted by `-`  \n- Characters within a word are separated by a single sp...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments