P14086 [ICPC 2023 Seoul R] Black Box

Description

The following $\texttt{Python}$-like pseudo code for function $\texttt {BlackBox()}$ takes a list of positive integers and shuffles the integers in the list in a specific way, and returns the result as a list. Three list methods are used below; For a list `L`, `len(L)` returns the number of items in `L`. `L.append(x)` adds the item `x` to the end of `L`. `L.pop(idx)` removes the item at the specified index `idx` from the list `L` and returns the removed item. Given a list $\texttt Z$ of positive integers, write a program to reconstruct a list $\texttt I$ such that $\texttt{Z = BlackBox(I)}$. ``` function BlackBox( Banana ): if len( Banana ) = 2 ) : Kiwi = Banana[ Mango ] Apple.append( Kiwi ) Banana.pop( Mango ) Papaya = Papaya - 1 Mango = ( Kiwi + Mango - 1 ) % Papaya # end of while Apple.append( Banana[ 0 ] ) Pear = len( Apple ) - 1 Orange = Apple[ Pear ] Lime = Apple[ 0 ] Coconut = Orange % Pear Melon = Apple[ Coconut ] Apple[ 0 ] = Melon Apple[ Coconut ] = Lime return ( Apple ) # end of function BlackBox ```

Input Format

Your program is to read from standard input. The first line contains a positive integer $𝑛$ representing the number of positive integers of a list $\texttt Z$, where $5 \le n\le 200,000$. The following $n$ lines contain $n$ positive integers of the list $\texttt Z$ returned from $\texttt {BlackBox(I)}$; the $i$-th line contains the $i$-th integer of the list $\texttt Z$ between $1$ and $100,000$, both inclusive.

Output Format

Your program is to write to standard output. Print $n$ integers of the list $\texttt I$ where $\texttt {Z = BlackBox(I)}$, one per line; the $i$-th line should contain the $i$-th integer of $\texttt I$.