No.3132 Encrypted Message
Problem Statement
This spring, you joined the competitive programming club, where exchanging encrypted messages is all the rage.
The encryption procedure is as follows.
- Prepare a message $S$, which is a string of length $N$ $(1\ \le\ N\ \le 100)$ consisting only of uppercase English letters.
- Create a sequence $A$ of length $N$ by converting the $i$-th character $S_i$ of the string $S$ into an integer $A_i$ according to the conversion table below.
* The letters $A$ through $Z$ correspond, in order, to $0$ through $25$.$S_i$ A 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_i$ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - Randomly choose $N$ values between $0$ and $1000$, inclusive, without duplicates, and arrange them in ascending order to obtain a sequence $B$ of length $N$.
-
Generate a sequence $C$ of length $N$ from the sequences $A$ and $B$ using the formula below.
- $C_i\ =\ 26\ \times\ B_i\ +\ A_i$ $(1\ \le\ i\ \le\ N)$
- Shuffle (randomly reorder) the sequence $C$ to obtain a sequence $D$ of length $N$, which is the encrypted message.
Here is a concrete example.
-
Let the prepared message $S$ be
"HELLO". Its length $N$ is $5$. -
Converting it according to the conversion table gives the sequence $A$ =
[7,4,11,11,14]. -
Let the sequence $B$, obtained by randomly choosing values without duplicates and arranging them in ascending order, be
[2,13,45,101,617]. -
Calculating $C_i\ =\ 26\ \times\ B_i\ +\ A_i$ gives the sequence $C$ =
[59,342,1181,2637,16056]. -
Let the sequence $D$, obtained by shuffling the sequence $C$, be
[2637,1181,59,16056,342]. This is the encrypted message.
A senior member of the competitive programming club has sent you an encrypted message. Decrypt it and read the message!
Input
$N$ $D_1\ D_2\ D_3\ \dots\ D_N$
Line 1 contains the length $N$ of the message. Line 2 contains the elements of the sequence $D$ of the encrypted message, separated by spaces.
$1\ \le\ N\ \le\ 100$
$0\ \le\ D_i\ \le\ 26025$ $(1\ \le\ i\ \le\ N)$
$D_i\ \neq\ D_j$ $(1\ \le\ i\ \lt\ j\ \le\ N)$
Output
$S$
Print the decrypted message $S$ on 1 line. End the output with a newline.
Sample
Sample 1
Input
5 2637 1181 59 16056 342
Output
HELLO
This is the encrypted message from the concrete example in the problem statement. Naturally, decrypting it gives "HEELO".
Sample 2
Input
15 23687 446 22319 22848 308 17799 2276 1545 1588 14614 7986 11896 2742 9327 19008
Output
WELCOMETOCPCLUB
"WELCOME TO CP CLUB" — it seems to be a message welcoming you to the club.
Sample 3
Input
18 5579 10261 22406 16380 9696 14381 17621 11173 20684 468 9803 4721 11343 19956 293 10070 17080 20226
Output
HAPPYBIRTHDAYTOYOU
"HAPPY BIRTHDAY TO YOU" — I hear that in the competitive programming world, there is a custom of giving sequences as birthday presents...
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ID 21712