Sherlock and the Ciphers
All submissions for this problem are available.
John Watson always knew that one of the favourite hobbies of Sherlock Holmes was to tinker with ciphers. Though Watson was not that good with ciphers, he learnt a few things being with him. Right now, Watson is in trouble! He has been locked in a room and the only way to get out of the room is through deciphering a known string to get the password. With his knowledge, he finds out that a given string S can be deciphered with a given cipher array A (1-based index) of same length N as follows: Starting from first number in A (i.e. i=1) the 'i'th character in S, has to be swapped with A[i]th character in S. Help him to get out of the room.
- First line contains no of test cases T. The description of T test cases follows.
- Each test case consists of 3 lines:
- Length of string N in the first line, the known string S in the second line, and N space-separated integers of array A in the third line.
- For each test case, output in a single line the deciphered text.
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 10^5
- 1 ≤ A[i] ≤ N
- Sum of N across all the test cases in a test file will not exceed 10^6
- String S contains only lower case English letters
3 5 abcde 1 2 3 4 5 6 fluxus 6 5 4 3 2 1 8 hrcksleo 5 5 7 5 6 8 7 8Output:
abcde fluxus sherlock
|Tags||cakewalk, dbyz2014, iiti_adm|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions