問題一覧 > 通常問題

No.2827 Enter User Name to Play

レベル : / AI推定難易度 : 101 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 155
作問者 : twitteryou / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 10939 / 自分の提出
問題文最終更新日: 2024-08-02 11:06:18
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 439 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。