Shuffle
InterviewTime limit2sMemory limit512 MB
Given a permutation of 27 characters, apply it N times to a short string and print the result.
- Level
Medium5 of 10
- Topics
- Implementation, Math, String, Simulation
- Solved
- No attempts yet
Problem
You want to keep some secrets, so you design a simple encryption scheme.
You map each uppercase letter and the underscore character to some other uppercase letter or underscore. In other words, you define a permutation — a one-to-one and onto map — of the 27-character set {'A', 'B', ..., 'Z', '_'} onto itself.
To make your message more secure, you apply this encryption repeatedly.
Input
The input consists of 29 lines.
- The first 27 lines each contain a single character from the set
{'A', 'B', ..., 'Z', '_'}. The first line is the character that'A'maps to, the second line is the character that'B'maps to, and so on up to the 26th line for'Z'; the 27th line is the character that the underscore'_'maps to. - The 28th line contains an integer (), the number of times the encryption is applied.
- The 29th line contains a string of fewer than 80 characters from the set
{'A', 'B', ..., 'Z', '_'}.
Output
Print, on a single line, the string obtained by applying the given permutation to exactly times.