P3988 [SHOI2013] Dealing Cards
Description
In some poker games, such as Texas hold'em, dealing has its own rules. The professional dealer is commonly called the dealer. Before dealing, the dealer needs to burn a card (burn card). Burning means moving the current top card of the deck to the bottom of the deck. This helps prevent players from guessing cards and affecting the game.
Suppose at the start, the dealer takes out a new deck with $N$ distinct cards labeled from $1$ to $N$. Since it is a new deck, the cards are in order from the top of the deck as $1, 2, \cdots, N$, with card $N$ at the bottom. To deal all cards, the dealer performs $N$ dealing operations. Before the $i$-th deal, he performs $R_i$ consecutive burn operations, where $R_i$ is given in the input. What is the final order of the cards received by the player?
For example, suppose $N=4$. Initially, the deck order is $1,2,3,4$.
- Suppose $R_1=2$. The dealer burns twice, moves $1$ and $2$ to the bottom, then deals $3$ to the player. The current deck order is $4,1,2$.
- Suppose $R_2=0$. The dealer does not burn and directly deals $4$ to the player. The current deck order is $1,2$.
- Suppose $R_3=3$. The dealer burns $1,2,1$ in order, then deals $2$ to the player. The deck now has only one card left, $1$.
- Suppose $R_4=2$. After burning $1$ twice again, the dealer still deals $1$ to the player because $1$ is the only card in the deck.
Input Format
The first line contains an integer $N$, the number of cards.
From the second line to line $N+1$, the $(i+1)$-th line contains an integer $R_i$.
Output Format
Output $N$ lines. On the $i$-th line, output one integer, the label of the $i$-th card received by the player.
Explanation/Hint
Constraints
For $100\%$ of the testdata, $0 \le R_i < N$.
| Test point ID | $N=$ | Test point ID | $N=$ |
| :----------: | :----------: | :----------: | :----------: |
| $1$ | $5\times 10^3$ | $6$ | $3\times 10^5$ |
| $2$ | $10^4$ | $7$ | $4\times 10^5$ |
| $3$ | $5\times 10^4$ | $8$ | $5\times 10^5$ |
| $4$ | $10^5$ | $9$ | $6\times 10^5$ |
| $5$ | $2\times 10^5$ | $10$ | $7\times 10^5$ |
Translated by ChatGPT 5