407220: GYM102697 191 Morbit Cipher Encryption

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

191. Morbit Cipher Encryptiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 35 points.

You're trying to encrypt text using the Morbit Cipher, a cipher involving morse code.

Encrypting text using the Morbit Cipher involves several steps:

1. Convert the text to Morse Code. This involves converting all letters to their Morse Code equivalents, and placing a lowercase x letter in between two letters, and two lowercase x letters in between two words. See below for a list of morse code mappings which you can copy into your program.

2. Divide the Morse Code into blocks of two characters each. If there are an odd number of characters, add an "x" to the end of the Morse Code. There are now 9 total combinations of two-character blocks, since each position can have three possible characters (dot, dash, and "x").

3. Write each of the 9 combinations of two-character blocks in an arbitrary order, assigning each one to an integer from 1 to 9. This is the "key" of the cipher.

4. Replace each two-character block in the Morse Code text of the cipher with the number it corresponds to in the key.

5. You should now have a long sequence of numbers from 1-9. Now, your text is encrypted using the Morbit Cipher.

Here is a comma-separated list of the Morse Code equivalents of each letter from A to Z, in order. You can copy this into your program:

".-", "-...", "-.-.", "-..", ".", "..-.", "–.", "....", "..", ".—", "-.-", ".-..", "–", "-.", —", ".–.", "–.-", ".-.", "...", "-", "..-", "...-", ".–", "-..-", "-.–", "–.."

Input

The first line of input contains a line of text, consisting of only lowercase characters and spaces: the plaintext to encrypt using the Morbit Cipher.

The next 9 lines each contain a two-character block: the first one corresponds to the block that maps to "1", the second one corresponds to the block that maps to "2", and so on.

Output

Output a single string of numbers from 1 to 9: the plaintext, after applying the Morbit Cipher on it using the given key.

ExamplesInput
we hope youre having fun in the competition so far
xx
.-
-.
x.
.x
..
--
-x
x-
Output
285465782341379742434166486245393163429545318664133979823494586979546971634825
Input
good luck in the rest of it
xx
.-
x-
.x
-.
-x
..
--
x.
Output
8486865495476553217343974495997318675173

加入题单

上一题 下一题 算法标签: