Submit | All submissions | Best solutions | Back to list |
SMPCPH1 - Substitution cipher |
You are given a sequence of n characters S = s1, s2, ..., sn in such a way that for i ≠ j we have also si ≠ sj. Your task is to substitute every si with si+1 for i in {1, 2, ... n-1} and sn with s1 in the given plain text.
Input
In the first line you are given one integer 2<=n<=26, and in the following line n characters.
In the third line you are given one integer 2<=m<=100, and in the following m lines you are given a plaintext to be encoded. Plaintext contains only white spaces and small letters from the Latin alphabet. The whole plain text is at most 1000 characters long.
Output
Encoded text, as specified above.
Example 1
Input: 6 spojit 3 after this training we will solve even difficult and tricky problems easily Output: afser shtp sratntng we wtll pjlve even dtfftculs and srtcky orjblemp eaptly
Example 2
Input: 10 dontgiveup 3 after this training we will solve even difficult and tricky problems easily Output: afgur ghvs gravtvti wu wvll snleu ueut ovffvcplg ato grvcky drnblums uasvly
Added by: | kuszi |
Date: | 2014-01-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments