CF 1462A - Favorite Sequence
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 個整數(shù)組成。 他在白板上寫下了如下內(nèi)容:
他把數(shù)字a1寫在左邊(在白板的開頭);他把數(shù)字a2寫在右邊(在白板的結(jié)尾);然后盡可能地向左寫(但從右邊寫) a1),他寫下了數(shù)字a3;
然后盡可能地向右(但在a2的左側(cè)),他寫下了數(shù)字a4;
波利卡普也繼續(xù)表演,直到他在白板上寫下了整個序列。
結(jié)果的開頭看起來像這樣(當(dāng)然,如果n≥4)。
例如,如果n=7且a=[3,1,4,1,5,9,2],則Polycarp將在白板上寫下一個序列[3,4,5,2,9,1,1] 。
您看到了寫在白板上的序列,現(xiàn)在您想要恢復(fù)波利卡普最喜歡的序列。
輸入
第一行包含一個正整數(shù) t (1≤t≤300) — 測試中測試用例的數(shù)量。 然后是測試用例。
每個測試用例的第一行包含一個整數(shù)n(1≤n≤300)——白板上寫的序列的長度。
下一行包含 n 個整數(shù) b1,b2,…,bn (1≤bi≤109) — 寫在白板上的序列。
輸出
輸出功率
? 測試用例的答案。 每個答案都是波利卡普在白板上寫下的一個序列 a。
--------------------------------------------------------------------------
利用雙指針去處理即可;