CCO '10 P6 - Shuffle

View as PDF

Submit solution

Points: 10
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2010 Stage 2, Day 2, Problem 3

You want to keep some secrets, so you invent a simple encryption algorithm.

You will map each uppercase character and underscore to some other uppercase character and underscore. In other words, this is a permutation of the characters, or, to put it another way, you create a 1:1 and onto map from \{A, B, \dots, Z, \_\ \} to \{A, B, \dots, Z, \_\ \}.

However, you will repeatedly apply this encryption in an attempt to make your message more secure.

Input Specification

The input will be 29 lines long. The first 27 lines will each contain a single character from the set \{A, B, \dots, Z, \_\ \}. The first of these lines represents what the character A maps to, the second of these lines represents what the character B maps to, and so on, until the 27^{th} line represents what the underscore character maps to. On the 28^{th} line will be an integer N\ (1 \le N \le 2\,000\,000\,000) which represents the number of times this encryption should be applied. On the 29^{th} line is T, a string of less than 80 characters from the set \{A, B, \dots, Z, \_\ \}.

Output Specification

On one line, output the string created after shuffling T a total of N times, using the given shuffle permutation.

Sample Input

B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
_
A
3
I_LOVE_THE_CCC

Sample Output

LCORYHCWKHCFFF

Comments


  • 0
    Riolku  commented on Nov. 22, 2018, 9:08 a.m.

    The CCC test data seems incorrect. Although they say that T will be less than 80 characters inspection of test data reveals that this is not the case.


    • 0
      Xue_Alex  commented on June 15, 2017, 7:19 p.m.

      to map from {A,B,…,Z,_}{A,B,…,Z,_} to {A,B,…,Z,_}{A,B,…,Z,_}.

      Yes.


  • 0
    TheZombieCloud  commented on June 14, 2017, 11:55 a.m.

    Unique

    Is every character's mapping unique? For example, some random character gets mapped to A, but another random character cannot get mapped to A.


    • 2
      Xue_Alex  commented on June 14, 2017, 11:58 a.m.

      Yes, each character's mapping is unique, if it weren't then some characters wouldn't be able to be mapped to.