欢迎光临散文网 会员登陆 & 注册

CF 1462A - Favorite Sequence

2023-07-26 13:04 作者:您是打尖儿还是住店呢  | 我要投稿

Polycarp has a favorite sequence a[1…n] consisting of n integers. He wrote it out on the whiteboard as follows:

he wrote the number a1 to the left side (at the beginning of the whiteboard);he wrote the number a2 to the right side (at the end of the whiteboard);then as far to the left as possible (but to the right from a1), he wrote the number a3;

then as far to the right as possible (but to the left from a2), he wrote the number a4;

Polycarp continued to act as well, until he wrote out the entire sequence on the whiteboard.

The beginning of the result looks like this (of course, if n≥4).

For example, if n=7 and a=[3,1,4,1,5,9,2], then Polycarp will write a sequence on the whiteboard [3,4,5,2,9,1,1].

You saw the sequence written on the whiteboard and now you want to restore Polycarp's favorite sequence.


Input

The first line contains a single positive integer t (1≤t≤300) — the number of test cases in the test. Then t test cases follow.


The first line of each test case contains an integer n (1≤n≤300) — the length of the sequence written on the whiteboard.


The next line contains n integers b1,b2,…,bn (1≤bi≤109) — the sequence written on the whiteboard.


Output

Output t

 answers to the test cases. Each answer — is a sequence a that Polycarp wrote out on the whiteboard.

---------------------------------------------------

Polycarp 最喜欢的序列 a[1…n] 由 n 个整数组成。 他在白板上写下了如下内容:

他把数字a1写在左边(在白板的开头);他把数字a2写在右边(在白板的结尾);然后尽可能地向左写(但从右边写) a1),他写下了数字a3;

然后尽可能地向右(但在a2的左侧),他写下了数字a4;

波利卡普也继续表演,直到他在白板上写下了整个序列。

结果的开头看起来像这样(当然,如果n≥4)。

例如,如果n=7且a=[3,1,4,1,5,9,2],则Polycarp将在白板上写下一个序列[3,4,5,2,9,1,1] 。

您看到了写在白板上的序列,现在您想要恢复波利卡普最喜欢的序列。


输入

第一行包含一个正整数 t (1≤t≤300) — 测试中测试用例的数量。 然后是测试用例。


每个测试用例的第一行包含一个整数n(1≤n≤300)——白板上写的序列的长度。


下一行包含 n 个整数 b1,b2,…,bn (1≤bi≤109) — 写在白板上的序列。


输出

输出功率

  测试用例的答案。 每个答案都是波利卡普在白板上写下的一个序列 a。

--------------------------------------------------------------------------

利用双指针去处理即可;


CF 1462A - Favorite Sequence的评论 (共 条)

分享到微博请遵守国家法律