2014 Mock CCC by Alex and Timothy
Alice's love potion failed because Bob overdosed. Now, her new tactic is
to impress Bob. Bob is a computer scientist who specializes in ropes. In
computer science, a rope is a data structure used for efficiently
manipulating strings. Bob has a rope of characters. However, it's too
long to fit in his pocket, so he folds it into segments. Each fold
is at a letter which is not the last. The fold takes the rest of the
rope after that letter, reverses it, and puts it above the current
letter. For example, the rope ABRACADABRA
, when folded
AB|RACA|DAB|RA
, yields:
AR
DAB
ACAR
AB
Alice notices that Bob often gets a headache pulling the rope out of his pocket and spending a long time untangling it. She concludes that if she finds a way to unfold it for Bob, Bob will be so impressed that he can't help but fall madly in love with her. You must write a program to help Alice!
Input Specification
The first line of input will contain the positive integer
, the number of lines to follow. The next lines each
contain a segment of the folded rope.
The entire unfolded rope will be no greater than characters, and
will only consist of uppercase letters from A
to Z
.
Output Specification
The output should contain one line — the unfolded rope.
Sample Input 1
4
AR
DAB
ACAR
AB
Sample Output 1
ABRACADABRA
Sample Input 2
5
D
LRO
W
OL
HEL
Sample Output 2
HELLOWORLD
Comments