No.2827 Enter User Name to Play
タグ : / 解いたユーザー数 155
作問者 :
Problem Statement
A boy is thinking of a username for a game. The boy has a nickname $S$ of $N$ characters, but since he does not want anyone to find out that he is playing this game, he has decided that his username will be a rearrangement of the characters of $S$.
You are given a positive integer $N$, a string $\ S=S_1S_2...S_N\ $ of length $N$, and a permutation $\ P = (P_1,P_2, \ldots,P_N)$ of $\ (1,2,\ldots,N)\ $. Find the string $\ T=T_1T_2...T_N\ $ such that $T_i$ is $S_{P_i}$ for every $i \ (1 \leq i \leq N)$. Here, a permutation means a sequence obtained by rearranging the elements of $(1,2,\ldots,N)\ $.
Input
$N$ $S$ $P_1 \ P_2 \ \ldots \ P_N$・$2 \leq N \leq 16$
・$N$ is an integer.
・$S$ is a string of $N$ lowercase English letters.
・$(P_1,P_2,\ldots,P_N)\ $ is a permutation of $\ (1,2,\ldots,N)\ $.
Output
Output the $T$ that satisfies the condition.
Sample
Sample 1
Input
3 abc 2 3 1
Output
bca
Since $\ T_1=S_{P_1}=S_2$, $T_2=S_{P_2}=S_3$, $T_3=S_{P_3}=S_1\ $, the expected output is bca.
Sample 2
Input
7 chatgpt 3 4 7 5 6 2 1
Output
attgphc
Sample 3
Input
13 happyhappycat 6 2 4 8 10 11 12 9 3 5 1 7 13
Output
happycappyhat
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。