11172 - Spiral Text - The Main Diagonal   

Description

In this problem, you are asked to rearrange a given text in a square and output its main diagonal (主對角線) in the "spiral form".

A square is an area with NxN grids. For a given text with length NxN, you put the first character in the upper-left grid. Then, you put the following N-1 characters to the right of the previous one, and you will reach the right border of the square. Any time you can't find an empty place on current direction, you turn "right" and place the next character untile you finish placing all characters and reach the center of the square.

The case below shows the result of a text "0123456789ABCDEF" in a 4x4 square:

0123
BCD4
AFE5
9876

And in this case, you should print "0CE6" as the answer.
 
Hint:
There are at least 2 strategies to solve this question. The first one is placing these texts in a square, while the other one is trying to find rules to fetch the main diagonal directly from the original text. Feel free to draw some cases on the paper we provided.

Input

There are 2 lines for the input. The first shows the integer N (1<= N <= 16) denotes the size of the edges of the square. The following line is a text with exactly NxN characters. There might be alphabets, numbers and spaces in the text.

If you use getchar() to fetch characters in the text, make sure you handle the "new line" ('\n') character in the first line properly.

Output

Print the characters in the main diagonal in a line. There should be exactly N characters folowing a new line ('\n') symbol.

Sample Input  Download

Sample Output  Download

Tags

I2P CS 2016 Lee Mid1



Discuss