#TP0000002. Dãy yêu thích (Favorite Sequence)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Dãy yêu thích (Favorite Sequence)
Favorite Sequence
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Polycarp has a sequence of integers . He writes it on a whiteboard in a special order. First, he places at the left end and at the right end. Next, he puts immediately to the right of and immediately to the left of .
He continues in the same manner: elements with odd indices fill the whiteboard from the left towards the center, while elements with even indices fill it from the right towards the center. Once all elements have been written, the visible sequence, from left to right, is .
Given the visible sequence , reconstruct Polycarp's original sequence . Values are not necessarily distinct; the reconstructed order must follow the writing procedure exactly.
Input
- The first line contains an integer , the sequence length.
- The second line contains exactly integers , in their current left-to-right order on the whiteboard.
Output
Print one line containing exactly integers , separated by spaces, in their original order.
Subtasks
- Subtask 1 (20 points): ; for every ; equal values are allowed.
- Subtask 2 (30 points): ; for every ; equal values are allowed.
- Subtask 3 (50 points): ; for every ; equal values are allowed.
Examples
Input
7
3 4 5 2 9 1 1
Output
3 1 4 1 5 9 2
Explanation
The leftmost is , and the rightmost is . Removing these two elements leaves , whose leftmost is and rightmost is .
The remaining sequence is : becomes and becomes . The final remaining element becomes . Thus the original sequence is .