Arranging the AppetizersProblem code: ARRANGE |
All submissions for this problem are available.
The Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will display the message. The Chef plans to display them in this order on a table that can be viewed by all guests as they enter. The appetizers will only be served once all guests are seated.
The appetizers are not necessarily finished in the same order as they are numbered. So, when an appetizer is finished the Chef will write the number on a piece of paper and place it beside the appetizer on a counter between the kitchen and the restaurant. A server will retrieve this appetizer and place it in the proper location according to the number written beside it.
The Chef has a penchant for binary numbers. The number of appetizers created is a power of 2, say n = 2k. Furthermore, he has written the number of the appetizer in binary with exactly k bits. That is, binary numbers with fewer than k bits are padded on the left with zeros so they are written with exactly k bits.
Unfortunately, this has unforeseen complications. A binary number still "looks" binary when it is written upside down. For example, the binary number "0101" looks like "1010" when read upside down and the binary number "110" looks like "011" (the Chef uses simple vertical lines to denote a 1 bit). The Chef didn't realize that the servers would read the numbers upside down so he doesn't rotate the paper when he places it on the counter. Thus, when the server picks up an appetizer they place it the location indexed by the binary number when it is read upside down.
You are given the message the chef intended to display and you are to display the message that will be displayed after the servers move all appetizers to their locations based on the binary numbers they read.
Input
The first line consists of a single integer T ? 25 indicating the number of test cases to follow. Each test case consists of a single line beginning with an integer 1 ? k ? 16 followed by a string of precisely 2k characters. The integer and the string are separated by a single space. The string has no spaces and is composed only of lower case letters from 'a' to 'z' .
Output
For each test case you are to output the scrambled message on a single line.
Example
Input: 2 2 chef 4 enjoyourapplepie Output: cehf eayejpuinpopolre
| Author: | friggstad |
| Date Added: | 9-08-2010 |
| Time Limit: | 5 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

tell how the answer cehf
tell how the answer cehf comes for 1st test case
It's clear from the problem
It's clear from the problem statement.
"he has written the number of
"he has written the number of the appetizer in binary with exactly k bits."
number of apetizers is n ... which is eqaual to 2k
for the first case
k is 2, so n is 4 .. how will 4 be written in k bits??
The description says the
The description says the appetizers are numbered from 0 to n-1.
he has written the number of
he has written the number of the appetizer in binary ?
how a,b,c are converted into binary ?
input
@santhosh: read the problem
@santhosh: read the problem statement carefully
Editorials Please !!!!!!
Editorials Please !!!!!!
@Admin: Is this problem
@Admin: Is this problem available in Practice Section now bcoz I want to submit my solution and Cook Off competition has ended
I want to submit my solution
I want to submit my solution just to check; can I submit it now. I am not seeing the submit button.
hi
hi
@Akash , U can submit the
@Akash , U can submit the solution in Practise area
link
I have submitted the solution
I have submitted the solution for this problem in python. I got the execution time of 14.24. How come my solution get accepted even with this time, when problem says a time limit of 5s. Can somebody please explain me about this ..??
I can't find the problem in
I can't find the problem in the practice area! ... where to find it exactly?
Ashwani - please read the
Ashwani - please read the FAQ.
Chandni - click on the link in Kumar's comment. (You can find more info in the FAQ).
I want to submit a solution
@bodmas: You cannot submit a