Smoke Signals
Time limit1sMemory limit1024 MB
Parse a 26-letter Morse table and four pause lengths, then decode a binary smoke-signal string into text.
- Level
Medium6 of 10
- Topics
- String, Implementation, Simulation, Hash map
- Solved
- No attempts yet
Problem

Figure 1: The Morse alphabet
Your friend is on a polar expedition, and to keep in touch she sends smoke signals encoded in Morse. You find it tedious to memorize the Morse alphabet, so you want to write a program that translates the signal for you. The input is a string of ones and zeros, where a run of ones corresponds to one smoke puff. Smoke puffs correspond to dashes and dots, and empty stretches correspond to pauses between dashes and dots, between letters, and between spaces.
Input
The first lines contain a table of the Morse code for every letter. Each such line contains one uppercase letter (A-Z), one space, and then the Morse encoding of that letter.
After the table comes a line with two distinct integers: and . is the number of ones that make up a dash, and is the number of ones that make up a dot.
Then comes a line with three distinct integers: , , and . zeros make up a pause between a dot and a dash, zeros signal a new letter, and zeros are one space.
Finally comes a line containing the number , followed by a string of ones and zeros.
Output
Your program must print one line containing the decoded message.