Morse Code
Time limit1sMemory limit1024 MB
Given a Morse code message with characters separated by spaces, the task is to decode it back into the original string of length N.
- Level
Easy2 of 10
- Topics
- String, Hash map, Implementation
- Solved
- No attempts yet
Problem
Hyemin has recently become interested in Morse code. Morse code writes letters and symbols by combining short and long signals. The encoding of each character is fixed in advance. For example, if a short signal is '.' and a long signal is '-', then the letter 'A' is written as '.-' and the digit 1 is written as '.----'. Knowing Morse code could help in an emergency when someone needs to call for rescue, so Hyemin plans to use it when chatting with friends in everyday life. Hyemin wants to check right away whether the Morse messages from friends were decoded correctly. Given a Morse message converted from a string of length made of the letters A-Z, the digits 0-9, and the symbols ',', '.', '?', ':', '-', and '@', write a program that decodes the message and prints the original string.
The table below lists how each character is written in Morse code. (The second and fourth columns are the Morse codes for the characters in the first and third columns. '.' is a short signal and '-' is a long signal.)
Input
The first line contains an integer (), the length of the string before it is converted to Morse code.
The second line contains the Morse code message. Short signals are '.' and long signals are '-'. The Morse code for each character is separated by a space.
The input never contains a message that cannot be decoded with the table above.
Output
Print the decoded original string of length without spaces.
Letters must be printed in uppercase.