Perfect Shuffle
Time limit1sMemory limit128 MB
Interleave the top and bottom halves of a card list to perform one perfect shuffle for each test case.
- Level
Easy2 of 10
- Topics
- Simulation, Array
- Solved
- No attempts yet
Problem
A perfect shuffle splits a deck exactly in half and then lays the cards down alternately from the two halves, starting with the top half.
Given a deck of cards, perform one perfect shuffle. If the number of cards is odd, the top half gets one more card than the bottom half.
Input
The input holds several test cases. Each test case begins with a line containing one integer , the number of cards (). Each of the next lines holds the name of a card, listed from the top of the deck down. A name is 1 to 80 characters long and contains only capital letters and dashes. Within one test case all card names are different. The input ends with a line containing a single 0.
Output
For each test case, print lines holding the deck after one perfect shuffle. Print no extra spaces, and print no blank line between test cases.