| 2024-2025 ICPC, Swiss Subregional |
|---|
| Finished |
You are a manager for a popular concert tour, and you are supposed to plan the lineup for each concert. The marketing department uses polls to give you updates on the optimal lineup.
The initial lineup consists of $$$n$$$ different artists numbered $$$1$$$ through $$$n$$$ in a certain order. After each poll, the marketing department will give you an update of the following form:
You will receive an even number $$$k$$$. This means you should remove the first $$$\frac{k}{2}$$$ artists with odd positions (1-indexed) from the lineup, and you should reverse the order of the first $$$\frac{k}{2}$$$ artists with even positions. The two operations are done simultaneously.
Output the resulting lineup after processing every update from marketing.
In the first line of input, you receive $$$t$$$ ($$$1 \leq t \leq 100$$$), the number of test cases. Then $$$t$$$ test cases follow.
The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$2 \leq n \leq 10^5$$$; $$$1 \leq q \lt n$$$), the initial number of artists and the number of updates.
The second line contains $$$n$$$ distinct integers $$$a_1,\dots,a_n$$$ ($$$1 \leq a_i \leq n$$$), the initial order of artists.
The third line contains $$$q$$$ even integers $$$k_1,\dots,k_q$$$ ($$$2 \leq k_i \leq n$$$), the updates from the marketing department.
It is guaranteed that $$$k_i$$$ is not greater than the current number of artists for every update. Additionally, it is guaranteed that the sum of $$$n$$$ over all test cases is not greater than $$$10^5$$$.
Print the final lineup after processing all updates.
19 21 2 3 4 5 6 7 8 94 6
8 6 2 9
In the first update of the first test case, the elements $$$1$$$ and $$$3$$$ will get removed, as they are in odd positions; then $$$2$$$ and $$$4$$$ will be reversed.
In the second update of the first test case, the elements $$$4$$$, $$$5$$$, and $$$7$$$ will get removed, and $$$2$$$, $$$6$$$, $$$8$$$ reverse their positions.
| Name |
|---|


