#P3988. Poker Card Dealing Simulation

    ID: 17236 Type: Default 1000ms 256MiB

Poker Card Dealing Simulation

Poker Card Dealing Simulation

In some poker games such as Texas Hold'em, the dealer (often called the "croupier") performs a process called burning a card before dealing to prevent card counting. Initially, a new deck of $N$ distinct cards numbered from $1$ to $N$ is arranged in order, with card $1$ on the top and card $N$ at the bottom. To deal all $N$ cards, the dealer repeats the following procedure for i = 1, 2, \dots, N:

  • Before dealing the i-th card, perform $R_i$ burn operations. In each burn operation, take the card at the top of the deck and move it to the bottom.
  • After burning, deal the card now at the top to the player.

For example, when $N = 4$ with burn counts $R_1=2, R_2=0, R_3=3, R_4=2$ the process is as follows:

  1. Initial deck: [1, 2, 3, 4]. Burn 2 cards:
    Burn 1: move card 1 to bottom → [2, 3, 4, 1].
    Burn 2: move card 2 to bottom → [3, 4, 1, 2].
    Deal: card 3 is dealt. Deck becomes [4, 1, 2].
  2. With deck [4, 1, 2] and $R_2=0$, deal card 4. Deck becomes [1, 2].
  3. With deck [1, 2] and $R_3=3$, perform burns:
    Burn 1: move card 1 to bottom → [2, 1].
    Burn 2: move card 2 to bottom → [1, 2].
    Burn 3: move card 1 to bottom → [2, 1].
    Deal: card 2 is dealt. Deck becomes [1].
  4. With deck [1] and $R_4=2$, burning operations do not change the deck. Deal the remaining card 1.

The final sequence of dealt cards is: 3 4 2 1.

inputFormat

The first line contains an integer $N$ representing the number of cards. The second line contains $N$ non-negative integers $R_1, R_2, \dots, R_N$ indicating the number of burn operations before dealing each card.

outputFormat

Output a single line containing $N$ integers representing the order in which the cards are dealt to the player, separated by a single space.

sample

4
2 0 3 2
3 4 2 1

</p>