CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » August Cook Off » Arranging the Appetizers

Arranging the Appetizers

Problem code: ARRANGE

  • All Submissions

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


  • Submit

Comments

  • Login or Register to post a comment.

tell how the answer cehf

theeporithirumugam @ 21 Aug 2010 09:34 PM

tell how the answer cehf comes for 1st test case

It's clear from the problem

zac_adm @ 21 Aug 2010 09:37 PM

It's clear from the problem statement.

"he has written the number of

bhanuvrat @ 21 Aug 2010 10:44 PM

"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

zac_adm @ 21 Aug 2010 10:51 PM

The description says the appetizers are numbered from 0 to n-1.

he has written the number of

kewlRV @ 21 Aug 2010 11:10 PM

he has written the number of the appetizer in binary  ?

how  a,b,c are converted into binary ?

input

santhosh.codechef @ 21 Aug 2010 11:32 PM
input   :enjoyourapplepie
output:eayejpuinpopolre

how these related to eachother..

@santhosh: read the problem

admin @ 21 Aug 2010 11:37 PM

@santhosh: read the problem statement carefully

Editorials Please !!!!!!

theeporithirumugam @ 22 Aug 2010 12:18 AM

Editorials Please !!!!!!

@Admin: Is this problem

umangkedia @ 22 Aug 2010 12:29 AM

@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

akashag1001 @ 22 Aug 2010 10:53 AM

I want to submit my solution just to check; can I submit it now. I am not seeing the submit button.

hi

swarnim singh @ 22 Aug 2010 06:57 PM

hi

@Akash , U can submit the

kumaranurag @ 22 Aug 2010 09:22 PM

@Akash , U can submit the solution in Practise area

link

I have submitted the solution

xenon_15 @ 22 Aug 2010 11:35 PM

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

chandniverma @ 23 Aug 2010 04:47 AM

I can't find the problem in the practice area! ... where to find it exactly?

Ashwani - please read the

triplem @ 23 Aug 2010 06:45 AM

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 @ 5 Jul 2011 07:29 PM
I want to submit a solution to this problem but the submit button is not enabled! why???

@bodmas: You cannot submit a

anup @ 5 Jul 2011 07:33 PM
@bodmas: You cannot submit a problem in a contest once the contest is over. However, we add all the contest problems to our practice section after the contest. For this problem, you can submit your solution here.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com